Python/ref math floor
来自菜鸟教程
<languages />
Python math.floor()方法
例
将数字四舍五入到最接近的整数:
# Import math library
import math
# Round numbers down to the
nearest integer
print(math.floor(0.6))
print(math.floor(1.4))
print(math.floor(5.3))
print(math.floor(-5.3))
print(math.floor(22.6))
print(math.floor(10.0))
定义和用法
The
math.floor()
方法根据需要将数字DOWN舍入到最接近的整数,然后返回结果。
Tip:
要将数字四舍五入到最接近的整数,请查看
math.ceil()
方法。
句法
math.floor(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 需要。指定要四舍五入的数字 |
技术细节
| 返回值: | An
|
| 变更记录: | Python 3+:返回一个
|