Python中的ceil()方法使用教程
作者:goldensun 时间:2022-02-01 05:15:11
ceil()方法返回x的值上限 - 不小于x的最小整数。
语法
以下是ceil()方法的语法:
import math
math.ceil( x )
注意:此函数是无法直接访问的,所以我们需要导入math模块,然后需要用math的静态对象来调用这个函数。
参数
x -- 这是一个数值表达式。
返回值
此方法返回不小于x的最小整数。
示例
下面的例子显示了ceil()方法的使用。
#!/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
标签:Python
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
细化解析:转换 SQL数据库时的疑难问题
2009-02-05 15:38:00
Flask框架debug与配置项的开启与设置详解
2022-04-11 17:05:58
![](https://img.aspxhome.com/file/2023/5/79675_0s.png)
ASP Framework_1_简介
2009-10-12 11:35:00
他们是如何不让我的Teleport和Webzip工作的?
2010-07-14 21:06:00
使用python判断jpeg图片的完整性实例
2021-10-05 19:50:09
Python queue模块功能大全
2023-02-23 23:42:27
python调用文字识别OCR轻松搞定验证码
2023-02-20 17:10:54
![](https://img.aspxhome.com/file/2023/4/89044_0s.png)
Oracle 9i轻松取得建表和索引的DDL语句
2010-07-16 13:09:00
你可能不知道的Python 技巧小结
2022-12-18 07:08:10
python Kmeans算法原理深入解析
2022-03-01 07:26:55
![](https://img.aspxhome.com/file/2023/8/95548_0s.png)
pyhton列表转换为数组的实例
2021-01-12 08:14:31
python生成随机图形验证码详解
2023-11-20 22:28:10
如何使用Iframe实现本页提交?
2010-06-05 12:36:00
一文带你搞懂JS中导入模块import和require的区别
2023-07-21 03:24:18
html风格tooltip效果的实现
2010-04-08 13:00:00
元素层叠级别及z-index剖析
2008-07-22 12:03:00
初学者学习Python好还是Java好
2021-03-16 21:48:32
用私有属性来拯救IE7缩放图片的失真
2009-03-03 13:57:00
![](https://img.aspxhome.com/file/UploadPic/20093/3/feed-22s.gif)
python中无法导入本地安装好的第三方库问题
2022-06-25 12:24:31
![](https://img.aspxhome.com/file/2023/8/91918_0s.png)
pyqt5 QProgressBar清空进度条的实例
2022-11-28 03:04:08