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
最后修改:2020 年 06 月 28 日
声明:无闻风博客|版权所有,违者必究|如未注明,均为原创| 转载:转载请注明原文链接