I'm experiencing a weird error (or is it a bug?) with the python codecs module. I'm using Python 2.7.4.
Suppose I want to read the following file called foo
:
0
aaaa
bbbb
cddd
dddddddd
Long sentence here which is not even read completely
The rest is ignored...
I use the following code for that:
import codecs
log = codecs.open('foo', encoding='utf8')
log.readline()
lines = log.readlines()
print ''.join(lines)
The result I get is
aaaa
bbbb
cddd
dddddddd
Long sentence here which is not even read com
As you see, the file is not read entirely!?!! Is there any explanation for that?
(The problem does not occur if I omit the call to "readline", or if I don't use any encoding... This is all very mysterious to me.)