/
yozer
/
FilesWorks
Обзор
Документация
Войти
/
yozer
/
FilesWorks
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
py.py
14 строк
595 B
Kit os
initial
15 май 2025, 16:07
15 май 2025, 16:07
1fcbbee
Код
Авторство
О чём код?
with open('1.txt', encoding='UTF-8') as f: with open('2.txt', encoding='UTF-8') as s: with open('3.txt', encoding='UTF-8') as t: files = [''.join(['1.txt\n', f.read()]), ''.join(['2.txt\n', s.read()]), ''.join(['3.txt\n', t.read()])] files.sort(key=len) with open('union', 'w', encoding='UTF-8') as u: u.write('') with open('union', 'a', encoding='UTF-8') as u: for i, x in enumerate(files): u.write(x.split(sep='\n')[0] + '\n' + str(i+1) + '\n') for s in x.split(sep='\n')[1:]: u.write(s + '\n')