
如何统计Python代码行数
1个回答
展开全部
def get_file_code_lines(path):
file = open(path)
content = file.readlines()
result = [c.strip() for c in content if c.strip()]
print(len(result))
if __name__ == "__main__":
get_file_code_lines("test2.py")
file = open(path)
content = file.readlines()
result = [c.strip() for c in content if c.strip()]
print(len(result))
if __name__ == "__main__":
get_file_code_lines("test2.py")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询