我正在尝试将使用API从GET请求中获得的json转换为我可以使用的字典。以下是我所做的:
response = requests.get(API)
response_dict = json.loads(response.json())
print(response_dict)
我知道错误:
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not dict
发布于 2022-02-03 10:08:40
仔细阅读错误。这表明response.json()
已经返回了一个dict
。不需要调用json.loads
(它接受字符串)。
response = requests.get(API)
response_dict = response.json()
这就是你所需要的。
https://stackoverflow.com/questions/70969275
复制相似问题