Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def remove_last_line(file_path, output_file_path):
- with open(file_path, 'r') as file:
- lines = file.readlines()
- with open(output_file_path, 'w') as output_file:
- output_file.writelines(lines[:-1])
- # Пример использования
- input_file_path = 'input.txt' # Путь к исходному файлу
- output_file_path = 'output.txt' # Путь к файлу с результатом
- remove_last_line(input_file_path, output_file_path)
- print("Последняя строка удалена из файла и результат записан в другой файл.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement