Search This Blog

Thursday, October 6

Append and Update json object python

import json

with open("knowledge.json", 'r') as f:
    data = json.load(f)

data["worksbuddy.com"]["google.com"]["input"].append([3,4])
data["worksbuddy.com"]["google.com"]["output"].append(6)

with open('knowledge.json', 'w') as f:
    f.write(json.dumps(data))



print(data)

No comments:

Post a Comment