【发布时间】:2021-10-02 06:13:49
【问题描述】:
如何从数组中获取字符串结果?
我的代码如下所示:
#Start 10 highest Results
print("High Results:")print("Doing request")
headers = {"content-type": "application/json", "Accept-Charset": "UTF-8", "ApiAccessKey": "ExampleKey", "ApiSecretKey": "Example Key"}response = requests.get("https://www.example.com/", headers=headers, verify=False)print("writing response code")print(response)
print(response.content ) # Return the raw bytes of the data payloadprint("----------------------------------")
json_object = json.loads(response.text)json_formatted_str = json.dumps(json_object, indent=2)print(json_formatted_str)
y = json.str(response.content)
#Display only High Resultsprint(y[0]["High"])
print("done")
我得到的错误:
Traceback (most recent call last):File "./CurlRequest.py", line 71, in <module>y = json.str(response.content)AttributeError: module 'json' has no attribute 'str'
【问题讨论】:
标签: python arrays json string curl