Добавлены файлы data.txt, script.py
This commit is contained in:
parent
b4cae9a4f0
commit
bf3b552b6a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.venv/
|
.venv/
|
||||||
|
output.txt
|
15
script.py
Normal file
15
script.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Открываем файл data.txt для чтения
|
||||||
|
with open('data.txt', 'r', encoding='utf-8') as file:
|
||||||
|
# Считываем все строки из файла
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
|
# Преобразуем данные: переводим все строки в верхний регистр и сортируем
|
||||||
|
transformed_lines = [line.strip().upper() for line in lines]
|
||||||
|
transformed_lines.sort()
|
||||||
|
|
||||||
|
# Записываем преобразованные данные в файл output.txt
|
||||||
|
with open('output.txt', 'w', encoding='utf-8') as file:
|
||||||
|
for line in transformed_lines:
|
||||||
|
file.write(line + '\n')
|
||||||
|
|
||||||
|
print("Данные успешно обработаны и записаны в output.txt")
|
Loading…
Reference in New Issue
Block a user