[Tutor] need some help with ascii hex
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.
> >>>* 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 ?
> Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor