import requests
import city
cityName = input("你想查询哪个城市?")
citycode = city.citycode[cityName]
url = "http://t.weather.sojson.com/api/weather/city/%s"%citycode
rp = requests.get(url)
d = rp.json()
print(d)
dd = '城市:'+ d['cityInfo']['city'] +'\n'\
+'温度 '+ d['data']['wendu']
print(dd)
harry -用python查询天气
最新推荐文章于 2024-04-25 10:13:21 发布