我收到以下信息JSON
数组从POST
的响应HTTP
要求:
[{
"username": "username_1",
"first_name": "",
"last_name": "",
"roles": "system_admin system_user",
"locale": "en",
"delete_at": 0,
"update_at": 1511335509393,
"create_at": 1511335500662,
"auth_service": "",
"email": "userid_1@provider_1.com",
"auth_data": "",
"position": "",
"nickname": "",
"id": "short-string-of-random-characters-1"
}, {
...
}
<more such objects>..]
鉴于typeof(response)
给我requests.models.Response
,我怎样才能解析它Python
?
看看json模块。更具体地说是“解码 JSON:”部分。
import json
import requests
response = requests.get() # api call
users = json.loads(response.text)
for user in users:
print(user['id'])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)