Python3: Reading a text/binary mixed file

random832 at fastmail.us random832 at fastmail.us
Tue Mar 10 08:41:35 EDT 2015


On Tue, Mar 10, 2015, at 00:01, Paulo da Silva wrote:
> For .pnm photo files I read the entire file (I needed it in memory
> anyway), splited a copy separated by b'\n', got the headers stuff and
> then used the original remaining bytes as the photo pixels.
> But this is very tricky! I am on linux, but if I ran this program on
> windows I needed to change it to "eat" also the '\r'.

Why? The file is the same file. If the .pnm format is allowed to have a
'\r' there, you're just as likely to have to deal with it in Linux.



More information about the Python-list mailing list