Загрузить файлы в «/»

This commit is contained in:
Злата Сухова 2025-03-06 17:16:22 +00:00
commit 5ec8073364
5 changed files with 20 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 @@
a

1
data.txt Normal file
View File

@ -0,0 +1 @@
17 18 10 3 6 20 14 10 18

1
output.txt Normal file
View File

@ -0,0 +1 @@
ПРИВЕТ МИР

15
script.py Normal file
View File

@ -0,0 +1,15 @@
# Создаём соответствие номеров букв и самих букв русского алфавита
alphabet = {i + 1: letter for i, letter in enumerate("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ")}
# Читаем закодированный текст из файла data.txt
with open("data.txt", "r", encoding="utf-8") as file:
numbers = file.read().strip().split(" ") # Разделяем по одиночному пробелу, чтобы сохранить их
# Преобразуем числа в буквы, а пробелы оставляем
decoded_text = "".join(alphabet.get(int(num), " ") if num.isdigit() else " " for num in numbers)
# Записываем результат в output.txt
with open("output.txt", "w", encoding="utf-8") as output_file:
output_file.write(decoded_text)
print("Файл output.txt создан с расшифрованным текстом.")