Python number methodceil()返回x的上限值-不小于x的最小整数。
import math math.ceil( x )
x - 这是一个数值表达式。
此方法返回不小于x的最小整数。
以下示例显示了ceil()方法的用法。
链接:https://www.learnfk.comhttps://www.learnfk.com/python/number-ceil.html
来源:LearnFk无涯教程网
#!/usr/bin/python import math # This will import math module print "math.ceil(-45.17) : ", math.ceil(-45.17) print "math.ceil(100.12) : ", math.ceil(100.12) print "math.ceil(100.72) : ", math.ceil(100.72) print "math.ceil(119L) : ", math.ceil(119L) print "math.ceil(math.pi) : ", math.ceil(math.pi)
当无涯教程运行上面的程序时,它产生以下输出-
math.ceil(-45.17) : -45.0 math.ceil(100.12) : 101.0 math.ceil(100.72) : 101.0 math.ceil(119L) : 119.0 math.ceil(math.pi) : 4.0
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)