向上取整

>>> import math
>>> math.ceil(3.5)
4
>>> math.ceil(3.4)
4
>>> 

向下取整

>>> math.floor(3.4)
3
>>> 

四舍五入

>>> round(3.4)
3
>>> round(3.5)
4
>>> 

取整部分

>>> math.trunc(3.5)
3
>>> 

 

相关文章: