0
我尝试读取这个ASCII文件与此json content
具有以下功能:如何阅读使用JSON内容的ASCII文件:ValueError异常
{ "directory": { "name": "/wiki", "files": { "file": [ { "name": "/wiki/a.txt", "digest": "97d37a2ff85fbe35e1bf8ad38934d8fb518a6a3fbeb9b0b9305ce98e992f9dd2 " },
{ "name": "/wiki/d.txt", "digest": "ef91ee1257c3faa49f86f343cfec66010e5810e99db9f42e88774f90cd5b95d9 " },] } } }
def readJsonFile(path):
with open(path) as json_file:
json_data = json.load(json_file)
return json_data
我得到这个error
没有JSON对象的可解码:
ValueError: No JSON object could be decoded
我试着用json.loads
,我得到的错误:
TypeError: expected string or buffer
我使用正确的功能吗?
无效JSON。在http://jsonlint.com/上查看,它会告诉你什么是错的。 –