Displaying better error message than “No JSON object could be decoded”

后端 未结 11 1085
既然无缘
既然无缘 2020-11-30 23:05

Python code to load data from some long complicated JSON file:

with open(filename, \"r\") as f:
  data = json.loads(f.read())

(note: the be

11条回答
  •  旧时难觅i
    2020-12-01 00:00

    I had a similar problem this was my code:

        json_file=json.dumps(pyJson)
        file = open("list.json",'w')
        file.write(json_file)  
    
        json_file = open("list.json","r")
        json_decoded = json.load(json_file)
        print json_decoded
    

    the problem was i had forgotten to file.close() I did it and fixed the problem.

提交回复
热议问题