Some people say that college students in school to code enough to 10W lines of code, also some people say, not to read the number of lines to write code, but to modify the number of lines of code ...
Whoever said it, the people who said it were kind of bull.
Cough, first set a small goal for yourself, 5W line code! Write code all day, when to 5W? In order to more accurately measure themselves, wrote a code to count the number of small programs, beginner programming can learn from the beginning to count their own lines of code
The program is simple, traversing the number of lines of code files, the number of rows of variables stored in a local file, you can add a timestamp
1 #CODING=GBK2 ImportOS3 Import Time4 5Seq ="'6n =07 Try:8With open ('Totallines','R') as P:9Seq =P.read ()Tenindex = Seq.find ('>>') Onen = Int (seq[index+2:]) A exceptValueError as E: -n =0 - exceptFilenotfounderror: then =0 -FileList = input ('Enter a file name with multiple filenames separated by a space:') -FileList = List (Filelist.split (sep=' ')) - forFileNameinchfileList: + Try: -with open (filename,'R') as F: +Lines =F.readlines () A forSinchlines: at " "Do not count into blank lines" " - ifs = ='\ n': - Continue -n + = 1 - exceptFilenotfounderror as E: - Print('filename or file path error, no file! ') inOs.system ('Pause') -Os._exit (1) to exceptOSError as E: + Print('file name is not valid') -Os.system ('Pause') theOs._exit (1) * Print(Time.strftime ('%y-%m-%d%h:%m:%s', Time.localtime (Time.time ())) +'lines of code >>'+ STR (n) +'\ n') $With open ('Totallines','a') as F:Panax NotoginsengF.write (Time.strftime ('%y-%m-%d%h:%m:%s', Time.localtime (Time.time ())) +'lines of code >>'+ STR (n) +'\ n') -Os.system ('Pause')
python--Code Statistics Applet