我有这个要求,但它有一个奇怪的行为和我有不同的价值得到一个需要。
以下是一个例子:
response = requests.get('https://api-prd.dev/analytics/api/properties?filter[a.id]=' + aid, headers=headers)
request = response.json()
print(":0:->>>> ", request['data'][0])指纹是这样的:
:0:->>>> {'type': 'id-snapshot-property', 'id': 'adblue_level_percentage', 'attributes': {'updateDate': '2022-10-07T13:39:32Z', 'value': '0'}}如何在adblue_level_percentage中获得值0
答复:request['data'][0]['attributes']['value']
发布于 2022-10-07 14:09:22
>>> import requests
>>> r = requests.get('https://api.github.com/events')
>>> r.json()
[{'repository': {'open_issues': 0, 'url': 'https://github.com/...'}}]发布于 2022-10-07 13:57:30
import json
response = requests.get('https://api-prd.dev/analytics/api/properties?filter[a.id]=' + aid, headers=headers)
request = json.loads(response)现在,您可以通过调用dict键来获取dict对象和获取值。
发布于 2022-10-07 14:09:21
response = requests.get('https://api-prd.dev/analytics/api/properties?filter[a.id]=' + aid, headers=headers)
data = response.json()这也应该是可行的。它还提供一个字典,您可以通过它的键访问。
https://stackoverflow.com/questions/73988241
复制相似问题