import math
acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'nextafter', 'perm', 'pi', 'pow', 'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'sumprod', 'tan', 'tanh', 'tau', 'trunc', 'ulp'
以下是常见的方法:
>>> import math
>>> math.ceil(9.1)
10
>>> #向上取整
>>> math.ceil(9.1)
10
>>> #向下取整
>>> math.floor(9.1)
9
>>> #round:四舍五入,(偶数).5-->舍去, (偶数).51-->入;(奇数).5-->入
>>> round(4.5)
4
>>> round(4.51)
5
>>> round(5.5)
6
>>> #math.pow(2,3)==>2的3次方
>>> math.pow(2,3)
8.0
>>> #math.sqrt(4)==>开平方根
>>> math.sqrt(4)
2.0
>>> math.e
2.718281828459045
>>> math.pi
3.141592653589793
>>> #fabs(-10)求绝对值
>>> math.fabs(-10)
10.0
>>> #abs是全局函数
>>> abs(-8)
8
>>> math.log(8,2)
3.0
>>> math.log2(8)
3.0