import math
#向上取整
>>> math.ceil(2.3)
3
>>> math.ceil(2.6)
3
#向下取整
>>> math.floor(2.3)
2
>>> math.floor(2.6)
2
#四舍五入
#向上取整
>>> math.ceil(2.3)
3
>>> math.ceil(2.6)
3
#向下取整
>>> math.floor(2.3)
2
>>> math.floor(2.6)
2
#四舍五入
>>> round(6.6)
7
>>> round(6.4)
6
>>> round(6.55)
7
=============================================
只要不是 .5 的形式,也就是小数位不为5,round基本用法就是四舍五入
除此之外,round用于圆整:
>>> round(6.5)
6 ---------------------》6是偶数
>>> round(7.5)
8 ---------------------》8是偶数