當前位置:成語大全網 - 新華字典 - 用python寫的獲取天氣預報的代碼總有錯誤,解決壹下。

用python寫的獲取天氣預報的代碼總有錯誤,解決壹下。

Weatherinfo=r.json() #在json後面放括號返回結果。否則,只能返回函數地址。

以下python3通過:

進口?要求

API URL = "/adat/city info/101010100 . html "

r=requests.get(ApiUrl)

weatherinfo=r.json()

打印?(weather info[" weather info "][" ptime "])

打印?(weather info[" weather info "][" temp 2 "])& gt;& gt& gt八點鐘

& gt& gt& gt5℃