python - Weird result with struct.pack? -
while messing around struct.pack() , socket.htons(), got results not make sense me...
>>> struct.pack("h", socket.htons(80)) '\x00p' >>> struct.pack("h", socket.htons(81)) '\x00q' >>> struct.pack("h", socket.htons(82)) '\x00r'
where p, q , r come , mean? can't find them in docs.
ascii codes p
, q
, r
80
, 81
, 82
.
>>> ord('p') 80
in interactive shell, printable characters printed themselves, instead of escaped using \xhh
format.
>>> hex(80) '0x50' >>> '\x50' 'p' >>> '\xff' '\xff'
Comments
Post a Comment