Guest User

Untitled

a guest
Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sat Jun 23 10:14:07 2018
  4.  
  5. @author: Sc
  6. """
  7.  
  8. import sys
  9. import re
  10.  
  11. if len(sys.argv) > 1:
  12. f = open(sys.argv[1], "rU",encoding='utf-8')
  13. else:
  14. f = open("wc.py","rU",encoding='utf-8')
  15. f = sys.stdin
  16.  
  17. codelinenum = 1
  18. for line in f.readlines():
  19. if (re.match(r'^ *\n',line) or line.startswith('#')):
  20. print(line,file=sys.stdout, end='')
  21. #elif(re.match(r"(^ *""")|(^ *''')"):
  22. else:
  23. print(codelinenum,line,file=sys.stdout, end='')
  24. codelinenum = codelinenum + 1
  25.  
  26. f.close()
Add Comment
Please, Sign In to add comment