import json
with open("listexamp.json") as l:
b = json.load(l)
del b['addresses'][0]
print(b['addresses'][0])
输出
python test.py
addy2
重写源文件
import json
with open("listexamp.json") as l:
b = json.load(l)
del b['addresses'][0]
print(b['addresses'][0])
with open("listexamp.json", 'w') as l:
json.dump(b, l)
因为您要在删除之前打印值:)
正确的代码是
输出
重写源文件
相关问题 更多 >
编程相关推荐