Unpacking problem

Chris Garland chrisgarland67 at gmail.com
Thu Mar 1 16:17:45 EST 2007


What's wrong here?

>>> from struct import unpack

I can unpack an unsigned char
>>> unpack('B','\x90')
(144,)

I can unpack a short
>>> unpack('h','\x06\x00')
(6,)

But an unsigned char & a short give me this
>>> unpack('Bh','\x90\x06\x00')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
struct.error: unpack str size does not match format
>>>




More information about the Python-list mailing list