当我尝试使用.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/