Python: How to Replace a Specific Field Value in a JSON File
import json
# 读取 json 文件
with open('data.json') as f:
data = json.load(f)
# 更新某个字段
data['field_name'] = 'new content'
# 写回 json 文件
with open('data.json', 'w') as f:
json.dump(data, f)
原文地址: https://www.cveoy.top/t/topic/lhKD 著作权归作者所有。请勿转载和采集!