View Code
1 import sys,os 2 3 def LineCounter(i_path): 4 res=0 5 f=open(i_path) 6 for lines in f: 7 res+=1 8 return res 9 10 if(__name__=='__main__'):11 allinall=012 for root, dirs, files in os.walk('ACM-ICPC'):13 for item in files:14 ext=item.split('.')15 ext=ext[-1]16 if(ext in ['cc','java','cpp','c','py','cxx']):17 path=root+'/'+item18 allinall+=LineCounter(path)19 print "Total lines of your code :",allinall