描述
floor(x) 函数返回一个小于或等于 x 的的最大整数(向下取整)
floor() 方法的语法:
import math # 导入 math 模块
print ("math.floor(-45.17) : ", math.floor(-45.17))
print ("math.floor(100.12) : ", math.floor(100.12))
print ("math.floor(100.72) : ", math.floor(100.72))
print ("math.floor(math.pi) : ", math.floor(math.pi))
以上实例运行后输出结果为:
math.floor(-45.17) : -46
math.floor(100.12) : 100
math.floor(100.72) : 100
math.floor(math.pi) : 3