- 舍弃小数部分
>>> math.trunc(12.533222)
12
>>> round(12.2544)
12
- 按给定小数位数四舍五入
>>> round(12.2544, 3)
12.254
- 向上取整
>>> math.ceil(12.4584)
13
- 向下取整
>>> math.floor(12.4584)
12
>>> math.trunc(12.533222)
12
>>> round(12.2544)
12
>>> round(12.2544, 3)
12.254
>>> math.ceil(12.4584)
13
>>> math.floor(12.4584)
12
转载于:https://www.cnblogs.com/bryant24/p/11422660.html