I want to read a file that contains also German and not only characters. I found that i can do like this
>>> import codecs >>> file = codecs.open('file.txt','r', encoding='UTF-8') >>> lines= file.readlines() This is working when i try to run my job in Python IDLE but when i try to run it from somewhere else does not give correct result. Have a idea?
open('file.txt', 'rb').readlines(), and then useprint(repr(line))for a line that you know contains the German characters, as well as what you expect it to be. This should help us determine what the encoding is.readlines()probably doesn't work in binary mode, tryprint(repr(open('file.txt', 'rb').read())), and then post all or a portion of the output.