[英]Python. Read specific data from JSON Url?
So I'm trying to do a roblox-to-discord bot in python, and i need to fetch specific data.所以我想在 python 中做一个 roblox-to-discord 机器人,我需要获取特定数据。 For example:
例如:
{
"status": "ok",
"user": "blahblahblah"
}
Code I've Tried:我试过的代码:
import json
import requests
response = requests.get('https://verify.eryn.io/api/user/971259772932337675')
print(json.loads(response.json)['status'])
Is there any way to only fetch for example the status??有没有办法只获取例如状态?
You can load a json object from a string using the json module:您可以使用 json 模块从字符串加载 json object:
import json
response = '{"status": "ok","user": "blahblahblah"}'
print(json.loads(response)['status'])
Then you can work with it as it was a dictionary然后你可以像字典一样使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.