Windows vs. file.read
python at mrabarnett.plus.com
Wed Sep 1 19:31:50 CEST 2010
On 01/09/2010 18:03, Mike wrote:
> I have a ppm file that python 2.5 on Windows XP cannot read
> Python on linux can read the file with no problem
> Python on Windows can read similar files.
> I've placed test code and data here:
> Within the directory ppm_test, type
> python ppm_test.py
> The chunk size commentary occurs only if file.read cannot read enough
> The commentary only occurs for the last file.
> Any ideas?
> Any ideas that don't require getting rid of Windows?
> It's not my option.
You should open the files in binary mode, not text mode, ie file(path,
"rb"). Text mode is the default. Not a problem on *nix because the line
ending is newline.
More information about the Python-list