【发布时间】:2020-01-20 14:26:27
【问题描述】:
如何从中获取 JSON 响应,当我打印 response 时,我只得到响应状态 200 而不是 JSON 树。
headers = {
'accept': 'application/json',
'Authorization': 'Bearer 123456789',
}
params = (
('interval', 'month'),
)
response = requests.get('https://api.peakon.com/v1/engagement/overview', headers=headers, params=params)
print(response)
【问题讨论】:
-
response.json()? -
为了将来参考,内置的 python 函数 'dir()' 返回一个对象属性的列表,所以在这种情况下使用 dir(response) 将返回一个你可以使用的所有方法的列表调用“响应”,包括 json,这是你想要的