python - 属性错误: 'Response' object has no attribute 'json'

标签 python json python-requests

当我尝试使用.json()requests 库中的响应对象的方法,我收到错误:

>>> import requests
>>> response = requests.get("http://example.com/myfile.json")
>>> response_json = response.json()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Response' object has no attribute 'json'

为什么我会收到此错误以及如何修复它?

最佳答案

您的requests库版本太旧。 JSON 支持是在近 2 年前发布的 0.12.1 版本中添加的。

当前发布的版本是2.2.1。

关于python - 属性错误: 'Response' object has no attribute 'json' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22412873/

相关文章:

python - Matlab filter() 与 SciPy lfilter()

python - 在 Python 中随机化列表

javascript - AngularJS 中的日期 json 对象 json

Python 请求不适用于网站 API,但适用于浏览器 (chrome)

python - HTTP 代码名称\\o/\\o- -o-/o\\在请求中代表什么?

python - 为什么 'x or y' 不返回 bool 值?

python - AWS SDK : botocore. 异常中的 Boto3 错误。NoCredentialsError:无法找到凭证

javascript - 重构 JSON 对象

javascript - 在 AngularJS 中为 jQuery 日期选择器动态设置最大限制

python - 如何在python3中为请求库的post方法传递嵌套的params对象?