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/上查看,它會告訴你什麼是錯的。 –