向下取整//
or math.floor()
-0.5 // 1
Out[2]: -1.0
0.5 // 1
Out[3]: 0.0
取整数位int()
int(-0.5 / 1)
Out[4]: 0
int(0.5 / 1)
Out[5]: 0
向上取整 math.ceil()
math.ceil(-0.5)
Out[10]: 0
math.ceil(0.5)
Out[11]: 1
四舍五入round()
round(1.6)
Out[17]: 2
round(1.2)
Out[18]: 1
网友评论