struct.unpack on 64-bit platforms
Georg Brandl
g.brandl-nospam at gmx.net
Thu Jun 22 12:33:17 EDT 2006
Nadav Samet wrote:
> 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?
Looking into the docs, prepending your format string with "=" should
make "L" exactly 32 bits on each platform.
Georg
More information about the Python-list
mailing list