Convert variable directly into a string (no ASCII)

"Martin v. Löwis" martin at v.loewis.de
Sat May 2 14:41:38 EDT 2009


> I need to print variables out over serial, however I need them to not be
> in ASCII, ie if the variable is 5 then print 5 not "5".
> 
> The function that writes to the serial port requires a string and I can
> send non-variables out with the string "/x05" for 5.
> 
> Is this even possible?

So you have a number N given, between 0 and 255, and you want to send
the byte whose ordinal is N. Right? Send chr(N).

HTH,
Martin



More information about the Python-list mailing list