整数向上、向下和四舍五入

import math

f = 29.4
print(math.ceil(f)) #向上取整
print(math.floor(f)) #向下取整
print(round(f)) #四舍五入
输出
30
29
29

猜你喜欢

转载自www.cnblogs.com/zhujinxin/p/10197999.html
今日推荐