gpt4 book ai didi

python - 从请求中获取 JSON 参数,我得到 : 'method' object is not subscriptable

转载 作者:太空宇宙 更新时间:2023-11-03 15:51:54 24 4
gpt4 key购买 nike

我正在尝试从加载了请求的 JSON 字符串中获取参数。

我想我尝试了我能想到的任何组合。

非常感谢任何提示。

我的代码是这样的:

r = requests.get(url, headers=headers)
json_string = r.json
status = json.dumps(json_string['httpStatusCode'])

我得到了

'method' object is not subscriptable

最佳答案

您收到的错误是因为您将“方法”对象分配给 json_string。
因为在 python 中,“方法”对象不可订阅。

要获得 JSON 响应,您必须这样做

json_string = r.json()

关于python - 从请求中获取 JSON 参数,我得到 : 'method' object is not subscriptable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46095622/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com