Help how do I read `word' variables from a binary file?

nomad nomad*** at ***freemail.absa.co.za
Mon Mar 26 07:57:31 EST 2001


Howzit,

I'm having trouble with reading a binary file properly in Python 2.0
on win32.  I'm stating explicitly that I'm using Win32 as I know that
you have to state when opening the file that it is for `br' as in
binary reading (I'm think this is due to intels little-endian
approach, but I could be wrong).

I can open the file without problems, and I can read from the file
without a hitch, _BUT_ the trouble comes in that some of the data
records in the file have fields that would be a double word or even a
normal word in C++, so in effect the data may be 0x80002310, but
python reads the data directly from the file, and as such is reading
hex bytes as (in this example) `10 23 00 80' etc.  I'm sure that there
must be a simple way to read in data like this, but I can't figure it
out.

Any help would be greatfully recieved.

TIA.



More information about the Python-list mailing list