python--Code Statistics Applet

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.