/
Visten
/
PythonBreedACourseForBeginners
Обзор
Документация
Войти
/
Visten
/
PythonBreedACourseForBeginners
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
SoloProject/Code.py
31 строка
881 B
Visten_Home
03.10.2023! М.P.P
03 окт 2023, 17:33
03 окт 2023, 17:33
9b6f690
Код
Авторство
О чём код?
import os def countlines(start, lines=0, header=True, begin_start=None): if header: print('{:>10} |{:>10} | {:<20}'.format('ADDED', 'TOTAL', 'FILE')) print('{:->11}|{:->11}|{:->20}'.format('', '', '')) for thing in os.listdir(start): thing = os.path.join(start, thing) if os.path.isfile(thing): if thing.endswith('.py'): with open(thing, 'r') as f: newlines = f.readlines() newlines = len(newlines) lines += newlines if begin_start is not None: reldir_of_thing = '.' + thing.replace(begin_start, '') else: reldir_of_thing = '.' + thing.replace(start, '') print('{:>10} |{:>10} | {:<20}'.format( newlines, lines, reldir_of_thing)) for thing in os.listdir(start): thing = os.path.join(start, thing) if os.path.isdir(thing): lines = countlines(thing, lines, header=False, begin_start=start) return lines