首页 > 解决方案 > JSONDecodeError 期望值:第 1 行第 1 列 (char 0) 与空数组响应

问题描述

我正在使用 Python 3.6 中的 requests 包发出 GET 请求,但出现上述错误。我在 curl 上尝试了相同的请求,并得到了响应:

{
  "value": []
}

像这样的空响应会导致错误吗?

标签: pythonpython-requests

解决方案


您必须将其转换为 json

import json
response = requests.get(url)
json.loads((response.content).decode('utf-8'))


推荐阅读