import json
filename = ‘lovely_number.json’
try:
with open(filename) as f_obj:
lovely_number = json.load(f_obj)
except FileNotFoundError:
username = input(“What is your lovely number? ”)
with open(filename, ‘w’) as f_obj:
json.dump(lovely_number, f_obj)
print(“We'll remember you lovely_number when you come back!”)
Помогите, пожалуйста, разобраться с проблемой. lovely_number.py находится в той же дирректории, что и сама программа, но выводит ошибку:
Traceback (most recent call last):
File “lovely_number.py”, line 8, in <module>
lovely_number = json.load(f_obj)
File “C:\Users\DGV\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py”, line 293, in load
return loads(fp.read(),
File “C:\Users\DGV\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py”, line 357, in loads
return _default_decoder.decode(s)
File “C:\Users\DGV\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Users\DGV\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)