Reading binary data
rschroev_nospam_ml at fastmail.fm
Wed Sep 10 21:06:39 CEST 2008
Aaron Scott schreef:
> Sorry, I had posted the wrong error. The error I am getting is:
> struct.error: unpack requires a string argument of length 12
> which doesn't make sense to me, since I'm specifically asking for 11.
That's because of padding. According to the docs, "By default, C numbers
are represented in the machine's native format and byte order, and
properly aligned by skipping pad bytes if necessary (according to the
rules used by the C compiler)". That means that struct.unpack() assumes
one byte of padding between the 3-character string and the first
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov
More information about the Python-list