I\'m using python 2.7. I\'ve tried many things like codecs but didn\'t work. How can I fix this.
myfile.txt
wörd
My code
It's the terminal encoding. Try to configure your terminal with the same encoding you are using in your file. I recomend you to use UTF-8.
By the way, is a good practice to decode-encode all your inputs-outputs to avoid problems:
f = open('test.txt','r')
for line in f:
l = unicode(line, encoding='utf-8')# decode the input
print l.encode('utf-8') # encode the output
f.close()