【发布时间】:2020-11-22 10:37:27
【问题描述】:
我正在使用 Python 3.x 和 lib requests。 有没有办法通过从 json 文件中放置整个路径而不首先下载整个 json 来获取特定值?
我有以下代码来获取天气数据:
import requests
data=requests.get('http.weatherdata.com/example.json')
current_wind=a.json()['features'][48]['properties']['value']
有没有办法像下面这样直接请求“当前风”?这可能会减少请求的流量。
import requests
current_wind=requests.get('http.weatherdata.com/example.json',['features'][48]['properties']['value'])
我一直在寻找那个特定的问题......几乎放弃了。 谢谢你的回答。
【问题讨论】:
-
这不是Python问题,而是关于天气数据API的问题。如果可能(我不知道那个 API),您将能够使用 Pyhon 准备足够的请求。
标签: python json api python-requests