Первый коммит

This commit is contained in:
Alexandr 2025-03-08 00:10:27 +03:00
commit 2f76f732f2
5 changed files with 32 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.venv/
output.txt

1
README.md Normal file
View File

@ -0,0 +1 @@
Задания не было

1
data.txt Normal file
View File

@ -0,0 +1 @@
Text dlya scripta

1
output.txt Normal file
View File

@ -0,0 +1 @@
text dlya scripta

27
script.py Normal file
View File

@ -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()