Python - string to hexbytes conversion - HELP!

Daniel Klein danielk at aracnet.com
Thu Dec 6 11:03:15 EST 2001


It looks like you need to import the xdrlib module and use the Packer
and Unpacker objects. I  have not experimented with these classes so
you are on your own here. Just thought I would point you in the right
direction.

Daniel Klein

On Wed, 05 Dec 2001 20:48:39 GMT, "me" <dhhnews0 at hotmail.com> wrote:

>I'm a newbie to Python and I am trying
>to convert a string of decimal numbers - read from raw_input
>to a series of hexbytes
>eg
>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)
>
>all this is to control a device from the serial port
>but I cannot seem to recall how to conver the input to my required output
>An hints or suggestion most appreciated! I've spend hours trying various
>built in's
>which I would prefer to use
>
>HELP!
>





More information about the Python-list mailing list