2016-09-28 54 views
0
正確上傳.json

到目前爲止,我已經產生了下面的代碼:檢索的wunderground

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":

W以下鏈接hereas,"temp_c":可以發現:

http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/CA/San_Francisco.json

我努力理解我,以獲取氣象數據做錯了什麼。

回答