Reading from a binary file in a portable way
Martin v. Loewis
martin at v.loewis.de
Thu Apr 18 02:46:11 EDT 2002
jb <egrossde at yahoo.de> writes:
> I should like to read a (binary) file x.y in a buffer and then do things
> like getting the 16 bit integer that is at the offset n, n+1 in the file
> (maybe lowbyte, then higyhbyte.
>
> Previously I did it only under MS-Windows where for example I could open the
> file with the flag O_BINARY but this is no longer possible under Linux.
If you can accept using the open() builtin, I recommend to pass it the
"b" flag; that works on all platforms.
Regards,
Martin
More information about the Python-list
mailing list