Convert variable directly into a string (no ASCII)
doomster at knuut.de
Sat May 2 14:47:51 EDT 2009
Justin Rajewski wrote:
> 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.
Take a look at the chr() function. For completeness, the complementary one
is ord(). However, also take a look at the 'struct' module, which is the
tool of choice if you want to do other formatting operations.
I seem to remember there was a third tool that can be used for similar
tasks, but I forgot which it was...
More information about the Python-list