重构模型训练
This commit is contained in:
parent
ee0380545f
commit
6628c42242
|
|
@ -0,0 +1,31 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
# 目录路径
|
||||
directory = "output"
|
||||
|
||||
# 确保目录存在
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
# 读取多个 JSON 文件并合并
|
||||
def merge_json_files(file_list, output_file):
|
||||
merged_data = []
|
||||
|
||||
# 遍历每个文件
|
||||
for file in file_list:
|
||||
with open(f"data/{file}", 'r', encoding='utf-8') as f:
|
||||
data = json.load(f) # 读取 JSON 文件
|
||||
merged_data.extend(data) # 合并数据
|
||||
|
||||
# 将合并后的数据写入新文件
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(merged_data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
# 文件列表
|
||||
files = ['互联网查询.json','天气查询.json','知识问答.json','作业考勤人数.json', '周计划作业内容.json', '周计划数量查询.json','施工人数.json','日计划作业内容.json','日计划数量查询.json','页面切换.json']
|
||||
output_file = 'output/merged_data.json'
|
||||
|
||||
# 执行合并
|
||||
merge_json_files(files, output_file)
|
||||
|
||||
print("合并完成,结果保存在 'merged_data.json'")
|
||||
Loading…
Reference in New Issue