json.loads在python中不起作用(来自“自动化无聊的东西”第14章)

时间:2018-11-28 17:03:25

标签: python json

我尝试从“自动化钻孔材料”的第14章输入命令,但收到错误消息。

>>> import json
>>> stringOfJsonData = '{"name": "Zophie", "isCat": true, "miceCaught": 0, "felineIQ": None}'
>>> jsonDataAsPythonValue = json.loads(stringOfJsonData)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    jsonDataAsPythonValue = json.loads(stringOfJsonData)
  File "C:\Python36\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Python36\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python36\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 64 (char 63)

1 个答案:

答案 0 :(得分:2)

.sub-menu不是有效的JSON值;在JSON中,等效值为None