数字类型转换
int(x [,base ]) 将x转换为一个整数
long(x [,base ]) 将x转换为一个长整数
float(x ) 将x转换到一个浮点数
complex(real [,imag ]) 创建一个复数
str(x ) 将对象 x 转换为字符串 string
repr(x ) 将对象 x 转换为表达式字符串
eval(str )#用来计算在字符串中的有效Python表达式,并返回一个对象
tuple(s ) #将序列 s 转换为一个元组
list(s ) #将序列 s 转换为一个列表
chr(x ) #将一个整数转换为一个字符 char c c++中字符和字符串 a b c ‘a’ “asfdsfs”
python math块
1、导入
import math
2、查看math中包含的内容
dir(math)
[‘doc‘, ‘file‘, ‘loader‘, ‘name‘, ‘package‘, ‘spec‘, ‘acos’, ‘acosh’, ‘asin’, ‘asinh’, ‘atan’, ‘atan2’, ‘atanh’, ‘ceil’, ‘copysign’, ‘cos’, ‘cosh’, ‘degrees’, ‘e’, ‘erf’, ‘erfc’, ‘exp’, ‘expm1’, ‘fabs’, ‘factorial’, ‘floor’, ‘fmod’, ‘frexp’, ‘fsum’, ‘gamma’, ‘gcd’, ‘hypot’, ‘inf’, ‘isclose’, ‘isfinite’, ‘isinf’, ‘isnan’, ‘ldexp