| Store | Cart

struct unpack help?

From: Emile van Sebille <emi...@fenx.com>
Thu, 11 Jul 2002 14:27:21 GMT
Scherer, Bill
> Here's a sample string of the struct:>> sampleStructString = "_782c1a08_p_void">> I know that the struct defines only two unsigned shorts.  That> would imply (to me, anyway) a format of 'HH'. But calcsize of> that is 4, while my string is 16 bytes. So>

If you know the expected results of the sample, you can pass in the
appropriate slice:

>>> struct.unpack('HH', s[1:5])
(14391, 25394)

>>> struct.unpack('II', s[1:9])
(1664235575L, 942694705L)

--

Emile van Sebille
emile at fenx.com

---------

Recent Messages in this Thread
Emile van Sebille Jul 11, 2002 02:27 pm
Erno Kuusela Jul 11, 2002 04:57 pm
Messages in this thread