import requests
import json
#Infrastructure API URL
url = "http://10.39.188.69/server-manager/tomcat/bimws/rest/v1/infrastructures/?format=json"
myResponse = requests.get(url, headers=headers, verify=False)
print myResponse
print(myResponse.status_code)
#print(myResponse.text)
print(myResponse.json)
输出我得到:
c:\automation>python rest_API.py
C:\Python27\lib\site-
packages\requests\packages\urllib3\connectionpool.py:852:
nsecureRequestWarning: Unverified HTTPS request is being made. Adding
certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/late/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:852:
nsecureRequestWarning: Unverified HTTPS request is being made. Adding certifica
e verification is strongly advised. See: https://urllib3.readthedocs.io/en/late
t/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
<Response [200]>
<bound method Response.json of <Response [200]>>
答案 0 :(得分:0)
尝试 myResponse.json()。 myResponse.json 返回 instancemethod 类型,而 myResponse.json()将返回 json数据。