26 lines
859 B
Python
26 lines
859 B
Python
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()
|