
1.向下取整
采用int强转即为向下取整
b = int(7.2) # 7
d = int(5.9) # 5
2.向上取整
math中的ceil函数
import math
print(math.ceil(4.1)) #5
print(math.ceil(4.9)) #5
3.四舍五入
round()函数
print(round(4.1)) #4
print(round(4.9)) #5
欢迎分享,转载请注明来源:内存溢出

1.向下取整
采用int强转即为向下取整
b = int(7.2) # 7
d = int(5.9) # 5
2.向上取整
math中的ceil函数
import math
print(math.ceil(4.1)) #5
print(math.ceil(4.9)) #5
3.四舍五入
round()函数
print(round(4.1)) #4
print(round(4.9)) #5
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)