I have the a json file whose contents is {"67790": {"1": {"kwh": 319.4}}}
. Now I create a dictionary a_dict
which I need to append it into the json file. I tried the following but was not able to do it correctly. Where I'm going wrong?
with open(DATA_FILENAME, 'a') as f:
json_obj = json.dump(a_dict, json.load(f)
f.write(json_obj)
f.close()
question from:https://stackoverflow.com/questions/18980039/how-to-append-in-a-json-file-in-python