Python data types and type conversions

• int 整数
• long 长整数
• float  浮点数,小数
• complex 复数
• boolean 布尔
• str 字符串
• list 列表
•  tuple 元组
• dict 字典

Function description
int(x [,base ]) : Convert x to an integer
float(x ) : Convert x to a floating point number
complex(real [,imag ]) : Create a complex number, real is the real part, and imag is imaginary part
str(x): converts object x to string
repr(x): converts object x to expression string
eval(str): evaluates a valid Python expression in string, and returns a
tuple of objects (s ) : convert sequence s to a tuple
list(s ) : convert sequence s to a list
chr(x ) : convert an integer to a Unicode character
ord(x ) : convert a character to its ASCII integer value
hex(x): converts an integer to a hexadecimal string
oct(x): converts an integer to an octal string
bin(x): converts an integer to a binary string

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325564106&siteId=291194637