19 lines
758 B
Python
19 lines
758 B
Python
import json
|
|
|
|
def merge_and_renumber_json(file1, file2, output_file):
|
|
with open(file1, 'r', encoding='utf-8') as f1:
|
|
data1 = json.load(f1)
|
|
with open(file2, 'r', encoding='utf-8') as f2:
|
|
data2 = json.load(f2)
|
|
|
|
merged_data = data1 + data2
|
|
|
|
for new_idx, item in enumerate(merged_data, start=1):
|
|
item['idx'] = new_idx
|
|
|
|
with open(output_file, 'w', encoding='utf-8') as f_out:
|
|
json.dump(merged_data, f_out, indent=2, ensure_ascii=False)
|
|
|
|
print(f"合并完成,输出文件为: {output_file}")
|
|
|
|
merge_and_renumber_json('/home/ubuntu/50T/fsy/layer2/QA/code/EN-single_select_includes_process.json', '/home/ubuntu/50T/fsy/layer2/QA/code/821_single_select.json', '/home/ubuntu/50T/fsy/layer2/QA/code/merged.json') |