[Python-talk] How to print a bunch o bytes in hex?
Shawn O'Shea
shawn at eth0.net
Wed Sep 23 12:36:19 EDT 2009
I was pretty sure there was something the standard library that did this. I
went to docs.python.org and in the search box entered 'hex'. There were a
large number of results for the binascii module.
http://docs.python.org/library/binascii.html
I believe you want to look at this function:
binascii.b2a_hex(*data*)
-Shawn
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 ???
>
>
>
> Bruce Labitt
> Autoliv Electronics
> 1011B Pawtucket Blvd, PO Box 1858
> Lowell, MA 01853
>
> Email: bruce.labitt at autoliv.com.
> Tel: (978) 674-6526
> Fax: (978) 674-6581
>
> ******************************
> Neither the footer nor anything else in this E-mail is intended to or
> constitutes an <br>electronic signature and/or legally binding agreement in
> the absence of an <br>express statement or Autoliv policy and/or procedure
> to the contrary.<br>This E-mail and any attachments hereto are Autoliv
> property and may contain legally <br>privileged, confidential and/or
> proprietary information.<br>The recipient of this E-mail is prohibited from
> distributing, copying, forwarding or in any way <br>disseminating any
> material contained within this E-mail without prior written <br>permission
> from the author. If you receive this E-mail in error, please <br>immediately
> notify the author and delete this E-mail. Autoliv disclaims all
> <br>responsibility and liability for the consequences of any person who
> fails to <br>abide by the terms herein. <br>
> ******************************
> _______________________________________________
> Python-talk mailing list
> Python-talk at dlslug.org
> http://dlslug.org/mailman/listinfo/python-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://dlslug.org/pipermail/python-talk/attachments/20090923/ddb2ef24/attachment.html>
More information about the Python-talk
mailing list