#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. # """Writing Unicode data to a file. """ #end_pymotw_header import codecs import sys encoding = sys.argv[1] filename = encoding + '.txt' print 'Reading from', filename with codecs.open(filename, mode='rt', encoding=encoding) as f: print repr(f.read())