python读取含中文的json

python读取含中文的json

import json
file_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(test)
    test['imagePath'] = 0
    print(test)
    with open("outjson.json", 'w') as f:
        json.dump(test, f, indent=2)

你可能感兴趣的:(json)