From 2f76f732f2c370d0369c61eb25b5c965e0dcf345 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Sat, 8 Mar 2025 00:10:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ README.md | 1 + data.txt | 1 + output.txt | 1 + script.py | 27 +++++++++++++++++++++++++++ 5 files changed, 32 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 data.txt create mode 100644 output.txt create mode 100644 script.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c136cf9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.venv/ +output.txt \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8dcd636 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Задания не было \ No newline at end of file diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..6ff8be0 --- /dev/null +++ b/data.txt @@ -0,0 +1 @@ +Text dlya scripta \ No newline at end of file diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..ef97ade --- /dev/null +++ b/output.txt @@ -0,0 +1 @@ +text dlya scripta \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000..49cfa65 --- /dev/null +++ b/script.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +def main(): + choice = input(" Выберите 'u' для перевода в верхний регистр или 'l' для перевода в нижний регистр: ").strip().lower() + + try: + with open('data.txt', 'r', encoding='utf-8') as infile: + data = infile.read() + except FileNotFoundError: + print("Файл data.txt не найден.") + return + + if choice == 'u': + output_data = data.upper() + elif choice == 'l': + output_data = data.lower() + else: + print("Некорректный ввод. Пожалуйста, введите 'u' или 'l'.") + return + + with open('output.txt', 'w', encoding='utf-8') as outfile: + outfile.write(output_data) + + print("Результат записан в файл output.txt") + +if __name__ == "__main__": + main()