lolamontes69

Python/ Strip punctuation and whitespace chars from a txt

May 19th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. from string import punctuation, whitespace
  2.  
  3. fin = open('foobar.txt')
  4. for line in fin:
  5.     message = line.strip().replace("\n","")
  6.     for a in line:
  7.        if (a in punctuation) or (a in whitespace): pass
  8.        else: print a
  9.  
  10. """ prints:
  11. e q u a l i t y
  12. """
Advertisement
Add Comment
Please, Sign In to add comment