#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. # """Reading a configuration file. """ #end_pymotw_header from ConfigParser import SafeConfigParser import codecs parser = SafeConfigParser() # Open the file with the correct encoding with codecs.open('unicode.ini', 'r', encoding='utf-8') as f: parser.readfp(f) password = parser.get('bug_tracker', 'password') print 'Password:', password.encode('utf-8') print 'Type :', type(password) print 'repr() :', repr(password)