Char to ASCII and back ?

Peter Hansen peter at engcorp.com
Fri Apr 25 09:14:28 EDT 2003


Jean-Paul Roy wrote:
> 
> How do you transform a char (or a one-char string) into the integer
> ascii code and back ? Say to code a message.

Others have answered the basic question, but I'm puzzled by your
example use case.  What do you mean, "to code a message"?  In
many cases, you would just want to send the string itself... it's
just a sequence of bytes in memory.  For example, if you are doing
socket communication, or talking through a serial port, you don't
do anything special to strings, you just send them as-is.

Or is it really just curiosity, in which case I can shut up again. :-)

-Peter




More information about the Python-list mailing list