Python使用天气网api接口获取天气数据
发布日期:2021-07-01 00:09:16 浏览次数:2 分类:技术文章

本文共 429 字,大约阅读时间需要 1 分钟。

import requestsrep = requests.get('http://www.tianqiapi.com/api?version=v6&appid=23035354&appsecret=8YvlPNrz&city=北京')rep.encoding = 'utf-8'print('返回结果:%s'%rep.json())print('城市:%s'%rep.json()['city'])print('天气:%s'%rep.json()['wea'])print('风向:%s'%rep.json()['win'])print('温度:%s'%rep.json()['tem']+'°C')print('风力:%s'%rep.json()['win_speed'])print('湿度:%s'%rep.json()['humidity'])print('空气质量:%s'%rep.json()['air_level'])

使用参数附加在网址后即可

转载地址:https://lztom.blog.csdn.net/article/details/104591816 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:如何在火车票退票免手续费
下一篇:simulink中scope图像显示添加图例

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月27日 00时10分55秒