[Tutor] need some help with ascii hex

francois schnell francois.schnell at gmail.com
Thu Aug 18 20:46:12 CEST 2005


I'm not a Tutor but I found this wich could help you:


 To convert character data to integers, you can use the ord()
> function, and to convert a number to hex notation you can use the
> hex() function.
> Example:
> >>>* data =3D "hello"
> *>>>* for char in data:
> *>>>*     print hex(ord(char))
> *
> Note that hex() returns a string, not a number.

On 18/08/05, nephish <nephish at xit.net> wrote:
> Hey there,
> i am using the serial module and trying to get some info over an RS232
> port. Seems to be comming in ok, but when i print it out, its in ASCII
> instead of hex. is there a way to have python read serial in hex bytes
> instead of ASCII ?
> thanks.
> shawn
> _______________________________________________
> 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/20050818/f5acdf54/attachment.htm

More information about the Tutor mailing list