Advertisement
rfmonk

codecs_open_read.py

Jan 29th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. #1/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. import codecs
  8. import sys
  9.  
  10. encoding = sys.argv[1]
  11. filename = encoding + '.txt'
  12.  
  13. print 'Reading from', filename
  14. with codecs.open(filename, mode='rt', encoding=encoding) as f:
  15.     print repr(f.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement