This article mainly introduces the statistical project in the total number of code in the Python script sharing, this article directly gives the implementation code, the need for friends can refer to the following
Recently you need to count the total number of lines of code in your project, write a Python applet, and have to say how concise Python is, if you write it in Java at least twice times the code.
def cfile (path):
Allfiles = Os.listdir (path)
For file in Allfiles:
Child = Os.path.join (path,file)
If Os.path.isdir (child):
filename,fileext= Os.path.splitext (Child)
#file type need to calculate
If fileext in ['. Java ', '. jsp ', '. html ', '. htm ', '. xml ', '. sql ', '. js ', '. FTL ', '. css ', '. Groovy ']:
countf = Len (open (Child, ' RU '). ReadLines ())
The analysis on the code here, the example is relatively simple.