用到的模塊python
代碼code
#!/usr/bin/env #coding:utf-8 import os import time def analysePath(basePath): for basedir,dirs,files in os.walk(basePath): for ofile in files: filePath = os.path.join(basedir,ofile) check_file(filePath) for odir in dirs: newBasePath = os.path.join(basedir,odir) analysePath(newBasePath) def check_file(filePath): global totalCount with open(filePath,'r') as f: lines = f.readlines() if 'User: cs_sharp' in ''.join(lines[0:10]): for line in lines: if ''.join(line.split()) == '':totalCount+=1 print len(lines),filePath totalCount = 0 if __name__ == '__main__': analysePath('D:\Projects\projectB') print totalCount