Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def combine_files(input_files, output_file):
- with open(output_file, 'w') as output:
- for file_name in input_files:
- with open(file_name, 'r') as input_file:
- output.write(input_file.read())
- # Пример использования
- input_files = []
- while True:
- file_name = input("Введите название файла (или 'quit' для завершения): ")
- if file_name == 'quit':
- break
- input_files.append(file_name)
- output_file = 'combined_file.txt' # Имя файла, в который будет объединено содержимое
- combine_files(input_files, output_file)
- print(f"Содержимое файлов успешно объединено в файл '{output_file}'.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement