大家好,我有一段代码获取表中的行数,然后请求它们,但是我得到了
json.decoder.JSONDecodeError:预期值:第1行第1列(字符 0)
答案 0 :(得分:1)
好像您正在尝试解析一个空字符串(或从一个空文件中读取)。最小的有效JSON字符串仍必须具有顶级数组或字典,即[]
或{}
是最小的有效JSON字符串。
import json
json.loads("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)