python - JSONDecodeError 期望值:第 1 行第 1 列 (char 0) 与空数组响应
问题描述
我正在使用 Python 3.6 中的 requests 包发出 GET 请求,但出现上述错误。我在 curl 上尝试了相同的请求,并得到了响应:
{
"value": []
}
像这样的空响应会导致错误吗?
解决方案
您必须将其转换为 json
import json
response = requests.get(url)
json.loads((response.content).decode('utf-8'))
推荐阅读
- c++ - 无法访问数学常数
- html - 输入类型=“文本区域”。在行尾换行
- c# - SignalR - 如果 roomName 包含 '(撇号),则未收到消息
- reactjs - 如何通过 github 页面上传和链接带有域名的 React 网站?
- javascript - Admin-on-rest - 将分页放在顶部
- css - 如何根据字符串长度有条件地在 Sass 上设置字体大小
- c++ - 在c中使用winsock2头文件和lib时在控制台中出错
- java - 如何从链表中反转堆栈?
- javascript - JavaScript 队列植入
- c# - 阅读 iText7 XObject QrCode c#