Musicreater/查看代码数.py

24 lines
651 B
Python
Raw Normal View History

2022-05-11 21:34:16 +08:00
# -*- conding: utf8 -*-
import os
m = 0
for path, dir_list, file_list in os.walk(r"./"):
for file_name in file_list:
2022-06-09 16:21:08 +08:00
if file_name.endswith('.py'):
2022-05-11 21:34:16 +08:00
file = os.path.join(path, file_name)
print("得到文件名:" + str(file))
for i in open(file, 'r', encoding="utf-8"):
code = i.replace(' ', '').replace('\n', '')
if code.startswith('#'):
continue
if code:
print("\t" + code)
m += 1
else:
pass
input("\n最终代码行数为:" + str(m))