简体   繁体   中英

unable to load json data

I am unable to load the json data & getting errors which mention below. My code is ,

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)

Getting error

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'

You dont actually need to import json

try this

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM