python 向上取整和向下取整

向上取整

使用 ceil()

import math

x = 0.55
x0 = math.ceil(x)
向下取整

使用 floor()

import math

x = 0.55
x1 = math.floor(x)

如下:

记录 | python向上取整和向下取整_向下取整