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 extra "\x00"?


-- 
Luyun Xie
http://magefromhell.blogspot.com/
(http://blog.hellmage.info/)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to