struct.unpack on 64-bit platforms

Nadav Samet thesamet at gmail.com
Thu Jun 22 12:30:26 EDT 2006


Hi,

I am trying to unpack a 32-bit unsigned integer from a string using
struct.unpack.
so using string.unpack('L', data)  would work fine on 32-bit systems,

But apparently, on 64-bit platforms it tries to read 64-bit unsigned
integer (since
that's what the C Type unsigned long means on 64-bit platforms).

So what's the way to make it read exactly 32-bits, on all platforms?

Thanks,
Nadav




More information about the Python-list mailing list