无法加载json数据

时间:2019-03-13 15:18:20

标签: python json python-3.x

我无法加载json数据并收到以下提到的错误。 我的代码是

import requests
import json

url = 'https://172.28.1.220//actifio/api/info/lsjobhistory?sessionid=cafc8f31-fb39-4020-8172-e8f0085004fd'

ret=requests.get(url,verify=False)
data=json.load(ret)

print(data)

遇到错误

Traceback (most recent call last):
  File "pr.py", line 7, in <module>
    data=json.load(ret)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 293, in load
    return loads(fp.read(),
AttributeError: 'Response' object has no attribute 'read'

1 个答案:

答案 0 :(得分:2)

您实际上不需要import json

尝试

import requests

url = 'https://172.28.1.220//actifio/api/info/lsjobhistory?sessionid=cafc8f31-fb39-4020-8172-e8f0085004fd'

ret = requests.get(url,verify=False)
data = ret.json()

print(data)