readline() or readlines() method can read the file up to the line where weird character ascii code 26 appears. I would like to read the entire file though. A simple example attached.
Your problem is similar to this discussion: http://stackoverflow.com/questions/405058/line-reading-chokes-on-0x1a On Python2, files are based on the fopen() C function, and on Windows files opened in text mode stop reading on the first character 26 (^Z, or EOF) The best solution here is probably to open the file in "universal" mode: f = open("test.txt", "rU") ...Or use Python3, which has a completely new implementation of the open() function.
History
Date
User
Action
Args
2022-04-11 14:57:31
admin
set
github: 59334
2012-06-21 22:05:46
amaury.forgeotdarc
set
status: open -> closednosy: + amaury.forgeotdarcmessages: + resolution: wont fix