我一直在尋找網絡,我找不到添加新的JSON數據到數組的方法。將新的JSON數據存儲到python中的現有文件中
示例:我想通過python添加player_two,player_three。
{
"players": {
"player_one": {
"name": "Bob",
"age": "0",
"email": "[email protected]"
}
}
}
我怎樣才能實現通過蟒蛇這樣做呢?
我已經試過什麼:
with open("/var/www/html/api/toons/details.json", 'w') as outfile:
json.dump(avatarDetails, outfile)
你試過了嗎?你有什麼錯誤? –
我只嘗試過json.dumps,但是什麼都不做。 – brownzilla
將現有的JSON加載到Python字典中,然後根據需要對其進行變異並保存完成。 – chucksmash