[Python-talk] How to print a bunch o bytes in hex?
Tyson Sawyer
tyson at j3.org
Wed Sep 23 13:14:57 EDT 2009
On Wed, Sep 23, 2009 at 11:57 AM, <bruce.labitt at autoliv.com> wrote:
> Is there a simple way to print bytes that have been received from a
> network?
> I just want to print out the hex representation of the bytes...
>
> Right now the bytes are in a string, printing that results in unprintable
> or unrecognizable characters.
>
> 00 89 af b9 ...
>
> Thanks!
>
> for x in mystring:
print "0x%02x" % x
--
Tyson D Sawyer
A strong conviction that something must be done is the parent
of many bad measures. - Daniel Webster
More information about the Python-talk
mailing list