From 81d44afc066d5e0f738f747423a8d6607c139010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D1=80=D0=BE=D1=87=D0=BD=D1=8B=D0=B9=20=D0=93?= =?UTF-8?q?=D1=80=D0=B8=D0=B3=D0=BE=D1=80=D0=B8=D0=B9?= Date: Tue, 4 Mar 2025 21:54:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=87=D1=82=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=D1=81=D1=8C=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA?= =?UTF-8?q?=D0=BE=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20data.txt=20=D0=B8=20s?= =?UTF-8?q?cript.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data.txt | 0 script.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 data.txt create mode 100644 script.py diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..e69de29 diff --git a/script.py b/script.py new file mode 100644 index 0000000..f65ed88 --- /dev/null +++ b/script.py @@ -0,0 +1,29 @@ +def main(): + # Запрашиваем у пользователя выбор + choice = input("Введите 'u' для перевода в верхний регистр или 'l' для перевода в нижний регистр: ").strip().lower() + + # Читаем содержимое файла data.txt + 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 + + # Записываем преобразованный текст в файл output.txt + with open('output.txt', 'w', encoding='utf-8') as outfile: + outfile.write(output_data) + + print("Результат записан в файл output.txt") + +if __name__ == "__main__": + main()