TypeError: the JSON object must be str, not 'bytes' 类型错误:JSON对象必须是字符串,而不是字节。
- 论坛
- TypeError: the JSON object must be str, not 'bytes' 类型错误:JSON对象必须是字符串,而不是字节。
7 浏览
TypeError: the JSON object must be str, not 'bytes' 类型错误:JSON对象必须是字符串,而不是字节。
我有以下非常基本的代码,会抛出一个TypeError错误:`TypeError: JSON对象必须是str类型,而不是'bytes'`:
import requests import json url = '我的url' user = '我的用户' pwd = '我的密码' response = requests.get(url, auth=(user, pwd)) if(response.ok): Data = json.loads(response.content)
我尝试将解码应用于Data变量,如下所示,但它抛出相同的错误:`jData = json.loads(response.content).decode('utf-8')`
有什么建议吗?