Python data type conversion
The basic data types provided by Python mainly include: Boolean type, integer type, floating point type, string, list, tuple, set, dictionary, date, etc.
Function Description
type(x) data type
of x int(x[,base]) converts x to an integer
long(x[,base]) converts x to a long
float(x) converts x to a float
complex( real [,imag ]) creates a complex number
str(x ) converts object x to string
repr(x ) converts object x to expression string
eval(str ) is used to evaluate valid Python expressions in strings, and returns an object
tuple(s) converts the sequence s to a tuple
list(s) converts the sequence s to a list
chr(x) converts an integer to a character
unichr(x) converts an integer to the Unicode character
ord (x ) converts a character to its integer value
hex(x ) converts an integer to a hexadecimal string
oct(x) converts an integer to an octal string