繁体   English   中英

为什么python JSON模块显示错误:json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

[英]Why does the python JSON module show the error : json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

我的 JSON 模块有问题。 我不知道为什么这是一个错误:

with open('Book Store Data','r+') as file:
    print(json.load(file))
    json_contents = json.load(file)

我不明白为什么第三行显示错误: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)但打印它很好。 我正在阅读的文件只是一个测试:

[{"name": "George", "degree": "Coding"}, {"name": "Connor", "degree": "Science"}]

您已通过第一次调用json.load到达文件json.load 首先将它分配给一个变量,然后打印它。 否则,呼叫file.seek(0)在调用之间json.load

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM