方法 | 描述 | 示例 |
math.pi | 返回圆周率 | >>> math.pi3.141592653589793 |
math.ceil(x) | 返回x浮动的上限 | >>> math.ceil(5.2)6.0 |
math.floor(x) | 返回x浮动的下限 | >>> math.floor(5.2)5.0 |
math.trunc(x) | 将数字截尾取整 | >>> math.trunc(5.2)5 |
math.fabs(x) | 返回x的绝对值 | >>> math.fabs(-5.2)5.2 |
math.fmod(x,y) | 返回x%y(取余) | >>> math.fmod(5,2) 1.0 |
math.modf(x) | 返回x小数和整数 | >>> math.modf(5.2)(0.20000000000000018, 5.0) |
math.factorial(x) | 返回x的阶乘 | >>> math.factorial(5)120 |
math.pow(x,y) | 返回x的y次方 | >>> math.pow(2,3)8.0 |
math.sPRt(x) | 返回x的平方根 | >>> math.sqrt(5) |
新闻热点
疑难解答