本文共 373 字,大约阅读时间需要 1 分钟。
import jsonfile_path = r"C:\Users\29939\Desktop\裂纹\Seg\裂纹1.json"with open(file_path, encoding='utf-8-sig', errors='ignore') as file: test = json.load(file) print("已成功读取JSON文件:", test) # 修改imagePath值为0 test['imagePath'] = 0 print("修改后的JSON数据:", test) with open("outjson.json", 'w') as f: json.dump(test, f, indent=2) 转载地址:http://byofk.baihongyu.com/