Re: why struct.pack behave like this

2010-05-20 Thread Dave Angel
Xie&Tian wrote: Hi When I use struct to pack binary data, I found this interesting behaviour: import struct struct.pack('B', 1) '\x01' struct.pack('H', 200) '\xc8\x00' struct.pack('BH',1, 200) '\x01\x00\xc8\x00' struct.calcsize('BH') 4 Wh

why struct.pack behave like this

2010-05-20 Thread
Hi When I use struct to pack binary data, I found this interesting behaviour: >>> import struct >>> struct.pack('B', 1) '\x01' >>> struct.pack('H', 200) '\xc8\x00' >>> struct.pack('BH',1, 200) '\x01\x00\xc8\x00' >>> struct.calcsize('BH') 4 Why does "struct.pack('BH',1, 200)" come out with an ext