pithon/script.py

15 lines
783 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# script.py
# Открываем файл data.txt для чтения с указанием кодировки utf-8
with open('data.txt', 'r', encoding='utf-8') as file:
# Считываем все строки из файла
data = file.readlines()
# Преобразуем данные: преобразуем все строки в верхний регистр
transformed_data = [line.upper() for line in data]
# Записываем изменённые данные в новый файл output.txt с указанием кодировки utf-8
with open('output.txt', 'w', encoding='utf-8') as output_file:
output_file.writelines(transformed_data)
print("Данные успешно преобразованы и записаны в файл output.txt")