[Tutor] Conversion question

Tom Green xchimeras at gmail.com
Tue May 5 01:42:30 CEST 2009


Thank you, I didn't realize it was that easy.  I tried binascii before and I
thought it didn't work properly.

I appreciate it.

Mike.

On Mon, May 4, 2009 at 7:40 PM, Emile van Sebille <emile at fenx.com> wrote:

> On 5/4/2009 4:17 PM Tom Green said...
>
>> First, thanks in advance for any insight on how to assist in making me a
>> better Python programmer.
>>
>> Here is my question.  I work with a lot of sockets and most of them
>> require hex data.  I am usually given a string of data to send to the
>> socket.  Example:
>>
>> "414243440d0a"
>>
>> Is there a way in Python to say this is a string of HEX characters like
>> Perl's pack?  Right now I have to take the string and add a \x to every two
>> values i.e. \x41\x42...
>>
>
>
> import binascii
> binascii.a2b_hex('41424344')
>
> Emile
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090504/4a662dbf/attachment.htm>


More information about the Tutor mailing list