首页 资讯 论坛 我的社区 搜索 用户

[脚本] 获取天气信息

无闻风
发表于 2019-09-14 12:42:00
0
1122
r = requests.get('http://wthrcdn.etouch.cn/weather_mini?city=%E5%91%BC%E5%85%B0')
    tqjson = r.json()
    rgx = re.compile("")#正则
    high = tqjson['data']['forecast'][0]['high']#最高温
    low = tqjson['data']['forecast'][0]['low']#最低温
    type = tqjson['data']['forecast'][0]['type']#天气类型 晴 多云等
    fengxiang = tqjson['data']['forecast'][0]['fengxiang']#风向
    fengli = rgx.search(tqjson['data']['forecast'][0]['fengli']).group(1).replace('<','小于').replace('>','大于')
    tishi = tqjson['data']['ganmao'];#提示感冒等信息
    msg = '今日天气:'+ type +'n最高温度:'+ high + 'n最低温度:' + low + 'n风向:' + fengxiang + "    " + fengli + 'n' + tishi

最后修改 2019-09-14 12:45:20
0
1122
用户评论
一起折腾