【发布时间】:2017-02-06 02:51:45
【问题描述】:
到目前为止,我已经生成了以下代码:
import requests
def weatherSearch():
Search = raw_input('Enter your location: ')
r = requests.get("http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/{}.json".format(Search))
weatherData = r.json()
print weatherData
weatherSearch()
例如,如果将Search 设置为London,则会产生:
http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/London.json
但是,这个 .json 文件不包含我要查找的温度:"temp_c":
而在以下链接中,可以找到"temp_c"::
http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/CA/San_Francisco.json
为了检索天气数据,我很难理解自己做错了什么。
【问题讨论】:
标签: python json python-2.7 python-requests