/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/lab-1126-003/main.py
16 строк
489 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
from pathlib import Path def longest_txt_file(folder: str) -> tuple[Path | None, int]: best: Path | None = None best_lines = -1 for path in Path(folder).glob("*.txt"): with path.open("r", encoding="utf-8") as f: count = sum(1 for _ in f) if count > best_lines: best_lines = count best = path return best, best_lines winner, line_count = longest_txt_file(".") if winner: print(winner, "— строк:", line_count)