python的ceil() 函数返回数字的上入整数。
ceil的语法格式为
import math math.ceil( x )
注意:ceil()是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。
参数:x -- 数值表达式;
返回值:函数返回数字的上入整数。
以下展示了使用 ceil() 方法的实例:
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
Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务