python 读写json

超链接:深度学习工作常用方法汇总,矩阵维度变化、图片、视频等操作,包含(torch、numpy、opencv等)


import json

# 读取json
with open(r".\1.json", 'r', encoding='utf-8') as load_f:
    load_dict = json.load(load_f)
    for object in load_dict['samples']:
        object['imageUrl'] = object['imageUrl'].replace('color', 'blank').replace('yuan_minimg', 'tga_minimg')

# 写入json
with open("./record.json", "w") as dump_f:
    json.dump(load_dict, dump_f)

你可能感兴趣的:(Python,python,json,开发语言)