猫史档案馆


【Python作品分享】weather模块【作品秀】

用户:七小鹿很奈斯七小鹿很奈斯查看:0 回复:0 评论:0 创建时间:2020-05-09T16:11:51


【作品展示】

center_image

 

【作品介绍】

可以获取某城市的温度信息

作者:七小鹿

QQ:2058044807

 

【作品源代码】

def weather(cityName):
    import requests
    ur喵weather_mini?city="+cityName
    response = requests.get(url)
    #print(response)
    weatherDict = response.json()
    city = weatherDict["data"]["city"]
    wendu = weatherDict["data"]["wendu"]+"°C"
    ganmao = weatherDict["data"]["ganmao"]
    type = weatherDict["data"]["forecast"][0]["type"]
    return("当前城市名:"+city+"\n当前温度:"+wendu+"\n"+ganmao+"\n天气类型:"+type)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页