📜  编辑json文件python代码示例

📅  最后修改于: 2022-03-11 14:46:17.941000             🧑  作者: Mango

代码示例2
a_dictionary = {"d": 4}

with open("sample_file.json", "r+") as file:
    data = json.load(file)    # get data from file
    update(a_dictionary)
    seek(0)
    json.dump(data, file)    # insert data in file