Python common data type conversion

Common data type conversion

aims

  • Understand the type of conversion action
  • Mastered the commonly used type conversion

function Explanation
int(x [,base ]) The integer x is converted to a
long(x [,base ]) The converted to a long integer x
float(x ) The transition to a floating point x
complex(real [,imag ]) Creating a complex
str(x ) The object is converted to a string x
repr(x ) The string object is converted to an expression x
eval(str ) Python expression for calculating effective in the string, and returns an object
tuple(s ) Converting the sequence s is a tuple
list(s ) Converting the sequence s is a list of
chr(x ) Convert an integer to a character
unichr(x ) Will be converted to an integer Unicode character
words (x) A character into its integer value
hex(x ) Convert an integer to a hexadecimal string
oct(x ) Convert an integer to an octal string

Guess you like

Origin www.cnblogs.com/yzg-14/p/12181746.html