统计代码行数,代码行数,TotalLine.py
统计代码行数,代码行数,TotalLine.py
TotalLine.py
#/usr/bin/pythonimport os#count the line of a single filedef CountLine(path): tempfile = open(path) res = 0 for lines in tempfile: res += 1 print "%s %d" %(path, res) #output the file path and lines return res#count the total line of a folder, sub folder includeddef TotalLine(path): total = 0 for root, dirs, files in os.walk(path): for item in files: ext = item.split('.') ext = ext[-1] #get the postfix of the file if(ext in ["cpp", "c", "h", "java", "py", "php"]): subpath = root + "/" + item total += CountLine(subpath) return totalprint "Input Path"path = raw_input()print TotalLine(path)
相关内容
- Python计算自然周和自然月的首日时间戳,python首日,因工
- python SSH暴力破解工具,pythonssh暴力破解,[Python]代码#!
- 一个用Python给Vim做的插件,PythonVim做插件,function! Go
- Python登录人人网并抓取新鲜事,python新鲜事,Python登录人
- python计算对角线有理函数插值,python对角线插值,''' p
- 练习python,,[Python]代码de
- 正态分布概率计算,态分布概率计算,[Python]代码de
- python中如果通过索引遍历列表,python索引遍列表,pytho
- 参数化建筑-基础-附表皮,建筑表皮,建筑立面# -*- co
- 递归查找文件,递归查找,[Python]代码#!
评论关闭