打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Python floor() 函数 | 菜鸟教程

Python floor() 函数

Python 数字


描述

floor() 返回数字的下舍整数。


语法

以下是 floor() 方法的语法:

import mathmath.floor( x )

注意:floor()是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。


参数

  • x -- 数值表达式。

返回值

返回数字的下舍整数。

实例

以下展示了使用 floor() 方法的实例:

#!/usr/bin/pythonimport math   # This will import math moduleprint '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(119L) : ', math.floor(119L)print 'math.floor(math.pi) : ', math.floor(math.pi)

以上实例运行后输出结果为:

math.floor(-45.17) : -46.0math.floor(100.12) : 100.0math.floor(100.72) : 100.0math.floor(119L) : 119.0math.floor(math.pi) : 3.0

Python 数字

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
python中sqrt是什么意思
Python标椎库(上篇)
第37天:Python math 模块
用Python玩转数据:python的函数、模块和包
python自学教程(三)函数与模块
import语句
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服