import os CHUNK_SIZE = 1024 write_path = os.path.join(os.getcwd(), 'task2_data_1.txt') read_path = os.path.join(os.getcwd(), 'task2_data_2.txt') try: write_file = open(write_path, 'a') read_file = open(read_path) except FileNotFoundError as e: exception_path = str(e).strip('[Errno 2] No such file or directory:')[1:-1] print(f'"{exception_path}" не существует') except PermissionError as e: exception_path = str(e).strip('[Errno 13] Permission denied:')[1:-1] print(f'Файл "{exception_path}" не доступен для чтения/записи') except IsADirectoryError as e: exception_path = str(e).strip('[Errno 21] Is a directory:')[1:-1] print(f'"{exception_path}" является директорией') else: write_file.write('\n\n\n') data = read_file.read(CHUNK_SIZE) write_file.write(data) while data: data = read_file.read(CHUNK_SIZE) write_file.write(data) # пожалуйста не мучайте меня я не хочу писать еще три expept'a os.rename('task2_data_1.txt', 'task2_data_all.txt') os.remove('task2_data_2.txt')