Guest User

Untitled

a guest
Mar 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #!python3
  2. # coding: utf-8
  3. """Trim white space from end of line."""
  4.  
  5. import sys
  6.  
  7. if len(sys.argv) < 2:
  8. sys.exit("Usage: eol.py FILENAME[S]")
  9.  
  10. for filename in sys.argv[1:]:
  11. try:
  12. with open(filename, "r") as finp:
  13. lines = finp.readlines()
  14. except Exception as err:
  15. print(err)
  16. else:
  17. with open(filename, "w") as fout:
  18. for line in lines:
  19. fout.write(line.rstrip()+"\n")
Add Comment
Please, Sign In to add comment