简单的统计代码程序

Posted on 2012-03-05 14:15  蛇小狼  阅读(182)  评论(0编辑  收藏  举报
# -*- coding: utf-8 -*-

import os,re

num = 0
for root, dis, files in os.walk('G:\\paopaoyu\\apps'):
    for fil in files:
        p = re.compile('\W*.py$')
        m = p.search(fil)
        if m:
            #print fil
            f = file(root + '\\' + fil)
            temp = 0
            while True:
                line = f.readline()
                if len(line) == 0:
                    break
                num += 1
                temp += 1
            print fil + '----' + str(temp)
            f.close()
print num