python批量修改json⽂件import json
servlet如何获取参数import os
path = 'G:\Desktop\要修改⽂件的⽬录'
dirs = os.listdir(path)
num_flag = 0
for file in dirs:                            # 循环读取路径下的⽂件并筛选输出
git下载github项目if os.path.splitext(file)[1] == ".json":  # 筛选csv⽂件
num_flag = num_flag +1
print(file , end=' ')
# print(os.path.join(path,file))
with open(os.path.join(path,file),'r') as load_f:clips4sale
load_dict = json.load(load_f)
load_dict['shapes'][0]['label'] = 'lian_mu_dan_gao1'
print(load_dict['shapes'][0]['label'])
mvc是什么?相互间有什么关系?
with open(os.path.join(path,file),'w') as dump_f:
json.dump(load_dict, dump_f)
if(num_flag == 0):
print('所选⽂件夹不存在json⽂件,请重新确认要选择的⽂件夹')language content
else:
python解析json文件print('共{}个json⽂件'.format(num_flag))

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。