pip install pyyaml python import yaml def merge_yaml_files(output_file, *input_files): merged_data = {} for file in input_files: with open(file, 'r') as f: data = yaml.safe_load(f) merged_data.update(data) with open(output_file, 'w') as f: yaml.safe_dump(merged_data, f) merge_yaml_files("merged.yaml", "file1.yaml", "file2.yaml", "file3.yaml") python import yaml def split_yaml_file(input_file, output_prefix): with open(input_file, 'r') as f: data = yaml.safe_load(f) for key, value in data.items(): output_file = f"{output_prefix}_{key}.yaml" with open(output_file, 'w') as output_f: temp_data = {key: value} yaml.safe_dump(temp_data, output_f) split_yaml_file("big_file.yaml", "output")


上一篇:
下一篇:
切换中文