Its a simple three lines code and i'm unable to understand the error.
(I'm trying to create a json file from python and then read and write from it.
Note: hi.json
is created everytime i run this code but then the error comes. I have tried both .loads and .load functions.)
Code:
import json
with open("hi.json","a+") as f:
d=f.read()
d3=json.loads(d)
Error:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File"C:\Users\minusv\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 354, in loads return _default_decoder.decode(s)
File"C:\Users\minusv\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File"C:\Users\minusv\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)