From bf3b552b6ac0dc32d9b8648618051281369e7188 Mon Sep 17 00:00:00 2001 From: stud179127 Date: Sat, 17 May 2025 02:38:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20data.txt,=20scr?= =?UTF-8?q?ipt.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + data.txt | 3 +++ script.py | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 data.txt create mode 100644 script.py diff --git a/.gitignore b/.gitignore index 21d0b89..c136cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .venv/ +output.txt \ No newline at end of file diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..3f1cc63 --- /dev/null +++ b/data.txt @@ -0,0 +1,3 @@ +машина +дом +спать \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000..971a815 --- /dev/null +++ b/script.py @@ -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") \ No newline at end of file