On Jan 7, 5:33 am, Matthew Barnett <mrabarn...@mrabarnett.plus.com>
wrote:
> mudit tuli wrote:
> > For a single byte, struct.pack('<B',<int>)
> > For two bytes, struct.pack('<H',<int>)
> > what if I want three bytes ?
>
> Four bytes and then discard the most-significant byte:
>
> struct.pack('<I', <int>)[ : -1]

AARRGGHH! network ordering is BIGendian, struct.pack('<..... is
LITTLEendian
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to