Python - string to hexbytes conversion - HELP!
Peter Hansen
peter at engcorp.com
Thu Dec 6 20:47:32 EST 2001
Carsten Gaebler wrote:
>
> me wrote:
>
> > if I do a read and get a='1234567'
> > I need an equivalent string to be
> > b=Chr(0x01)+chr(0x23)+chr(x045)+chr(0x67)
>
> >>> import binascii
> >>> binascii.unhexlify("01234567")
> '\x01#Eg'
Other than the requirement that an *even* number of
digits be present (to ensure no partial bytes) this
one pretty much closes the discussion, doesn't it? :-)
--
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com
More information about the Python-list
mailing list