我是蟒蛇的新手。誰能告訴我如何從 python 中的給定 API 下載 JSON 文件,然后使用 mako 或 jinja 保存為 HTML?使用python腳本通過API從網(wǎng)上下載JSON。API 使用http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22
2 回答

HUX布斯
TA貢獻1876條經(jīng)驗 獲得超6個贊
您使用 requests 模塊通過以下代碼獲取 json
import requests
url = "http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22"
res = requests.get(url)
if res.ok:
res.json()
有關其他資源,您可以點擊此鏈接
添加回答
舉報
0/150
提交
取消