在 python 中获取单个 Json 值
Getting a single Json value in python
我有这个 API 响应,我想获取一些值并将它们存储为 python BOT 的变量,例如 'floor_price'(我想要它后面的整数)但出于某种原因,它不起作用,它一直给我错误,但是当我用 'stats' 尝试它时,它起作用并提供了一切。
API https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats
url = "https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats"
headers = {"Accept": "application/json"}
response = requests.request("GET", url)
json_response = response.json()
floor= json_response['floor_price']
请帮忙:)
url = "https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats"
headers = {"Accept": "application/json"}
response = requests.request("GET", url)
json_response = response.json()
floor= json_response['stats']['floor_price']
学分:@kindall
我有这个 API 响应,我想获取一些值并将它们存储为 python BOT 的变量,例如 'floor_price'(我想要它后面的整数)但出于某种原因,它不起作用,它一直给我错误,但是当我用 'stats' 尝试它时,它起作用并提供了一切。
API https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats
url = "https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats"
headers = {"Accept": "application/json"}
response = requests.request("GET", url)
json_response = response.json()
floor= json_response['floor_price']
请帮忙:)
url = "https://api.opensea.io/api/v1/collection/ogcats-harvest-galaxy/stats"
headers = {"Accept": "application/json"}
response = requests.request("GET", url)
json_response = response.json()
floor= json_response['stats']['floor_price']
学分:@kindall