Convert string to number
Import string
ts = ' 123 '
num = string.atoi (TS)
int (x [, Base]) converts x to an integer long (x [, Base]) convert x to a long integer Float (x) convert x to a floating-point number complex (real [, Imag]) Create a complex number STR (x) Convert object x to string REPR (x) Convert object x to expression string eval (str) is used to compute a valid Python expression in a string and returns an object tuple (s) &NBSP ; Convert sequence s to a tuple list (s) to convert sequence s to a list of &N Bsp Chr (x) Convert an integer to a character UNICHR (x) Convert an integer to Unicode character ord (x) &NBSP ; Converts a character to its integer value   Hex (x) Convert an integer to a hexadecimal string Oct (x) &nbs P Convert an integer to a octal string
Convert numbers to Strings
num = 322
str = '%d '%num
#str即为num转换成的字符串
Commonly used formatting strings:
%d integer
%f floating-point numbers
%e Science Count