commit 2f76f732f2c370d0369c61eb25b5c965e0dcf345 Author: Alexandr Date: Sat Mar 8 00:10:27 2025 +0300 Первый коммит 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()