import jsonfr = open("D:\\天气预报json.txt","rt",encoding="utf-8")str = fr.read()# str = '''# {# "reason":"查询成功",# "result":{# "city":"苏州",# "realtime":{# "temperature":"4",# "humidity":"82",# "info":"阴",# "wid":"02",# "direct":"西北风",# "power":"3级",# "aqi":"80"# },# "future":[# {# "date":"2019-02-22",# "temperature":"1/7°C",# "weather":"小雨转多云",# "wid":{# "day":"07",# "night":"01"# },# "direct":"北风转西北风"# },# {# "date":"2019-02-23",# "temperature":"2/11°C",# "weather":"多云转阴",# "wid":{# "day":"01",# "night":"02"# },# "direct":"北风转东北风"# },# {# "date":"2019-02-24",# "temperature":"6/12°C",# "weather":"多云",# "wid":{# "day":"01",# "night":"01"# },# "direct":"东北风转北风"# },# {# "date":"2019-02-25",# "temperature":"5/12°C",# "weather":"小雨转多云",# "wid":{# "day":"07",# "night":"01"# },# "direct":"东北风"# },# {# "date":"2019-02-26",# "temperature":"5/11°C",# "weather":"多云转小雨",# "wid":{# "day":"01",# "night":"07"# },# "direct":"东北风"# }# ]# },# "error_code":0# }'''ls = json.loads(str)# ls['result']['future'][]['weather']for i in range(5):print("{}:{}".format(ls['result']['future'][i]['date'],ls['result']['future'][i]['weather']))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。