用户:
不太聪明的圆形喵查看:1 回复:2 评论:1 创建时间:2022-04-09T14:31:13
【作品展示】

【作品介绍】
天气预报,看看吧!
【作品源代码】
import requests
import json
city = input('请输入查询的城市(汉字):')
url = 'http://wthrcdn.etouch.cn/weather_mini?city=' + city
res = requests.get(url)
data_json = json.loads(res.text)
data = data_json['data']
print('城市:' + data['city'])
print('温馨提示:' + data['ganmao'])
print('温度:' + data['wendu'] + '℃')
print('-------------------------------------------------------------------------------')
print('昨天日期:' + data['yesterday']['date'])
print('昨天天气:' + data['yesterday']['type'])
print('昨天最高温度:' + data['yesterday']['high'])
print('昨天最低温度:' + data['yesterday']['low'])
print('-------------------------------------------------------------------------------')
for i in range(0, 3):
print('日期:' + data['forecast'][i]['date'])
print('最高温度' + data['forecast'][i]['high'])
print('最低温度' + data['forecast'][i]['low'])
print('风向:' + data['forecast'][i]['fengxiang'])
print('-----------------------------------')
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn