Oct-30-2021, 11:06 AM
(This post was last modified: Oct-30-2021, 11:06 AM by JgKSuperstar.)
Hello, how do I solve this problem?
import json def write_json(new_date, filename='data.json'): try: with open(filename, 'r+') as file: #First we load existing data into a dict. (Önce mevcut verileri bir dict'e yüklüyoruz) file_data = json.load(file) file_data["emp_details"].append(new_date) # Sets file's current position at offset. (Dosyanın geçerli konumunu ofset olarak ayarlar.) file.seek(0) # convert back to json. (Json'a dönüştür.) json.dump(file_data, file, indent=4) # python object to be appended (Eklenecek python nesnesi) except json.decoder.JSONDecodeError: return y = {"emp_name":"Nikhil", "email": "[email protected]", "job_profile": "Full Time" } write_json(y)
Error: raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)