import requests
import json
list1=['day','week','wea','tem','tem1','tem2','win','win_speed','air_level','air_tips']
list2= ['' , '' , '天气: ','温度: ','最高温度: ','最低温度: ','风向: ','风速: ','空气质量: ','建议: ']
def show(days):
for i in range(10):
r=str(list2[i])+str(days[list1[i]])
print(r)
def show2(days):
for i in range(8):
r=str(list2[i])+str(days[list1[i]])
print(r)
while(True):
a=int(input("您想要查询近几天的天气? "))
while(a>7):
print('可查询近一周天气状况')
a=int(input("您想要查询近几天的天气? "))
res=requests.get("https://www.)
res.enconding ='utf-8'
result=json.loads(res.text)
b=result['data']
print("%s\n%s\n更新时间 :%s"%(result['country'],result['city'],result['update_time']))
print('================================================')
for i in range(a):
day=b[i]
if i==0:
show(day)
print('================================================')
else:
show2(day)
print('================================================')