且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python ValueError:无法解码JSON对象

更新时间:2022-06-16 10:47:40

.read()方法可能会将光标移动到文件末尾.试试:

It's possible the .read() method is moving the cursor to the end of the file. Try:

for filename in filenames:
    with open(os.path.join(dirname,filename)) as fd:
        json_data = json.load(fd)

看看哪里能找到你.

这当然假定您具有有效的JSON ,如您的示例所示. (请注意结尾的逗号)

This, of course, assumes you have valid JSON, as your example demonstrates. (Look out for trailing commas)