On Mon, 10 May 2010 03:33:51 am Jan Jansen wrote:
> Hello,
>
> I've got some trouble reading binary files with struct.unpack on
> windows. 
[...] 
> The code I'm using to check the first 80 bytes of the file is:
>
> import struct
> import sys
>
> with open(sys.argv[1]) as source:

You're opening the file in text mode. On Linux, there's no difference, 
but on Windows, it will do strange things to the end of lines. You need 
to open the file in binary mode:

open(sys.argv[1], 'rb') 



-- 
Steven D'Aprano
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to