python floor() 函数
2016-11-30 16:42
162 查看
Python floor() 函数
描述floor() 函数返回数字的下舍整数。
可以和 ceil() 函数对比来记。
语法
import math math.floor(x)
注意:floor() 函数是不能直接访问的,需要导入 math 模块,通过静态对象调用该方法。
参数
x 数值表达式
返回值
返回数字的下舍整数。
实例
# -*- coding: UTF-8 -*- import 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(119L) : ", math.floor(119L) print "math.floor(math.pi) : ", math.floor(math.pi)
输出:
math.floor(-45.17) : -46.0 math.floor(100.12) : 100.0 math.floor(100.72) : 100.0 math.floor(119L) : 119.0 math.floor(math.pi) : 3.0
相关文章推荐
- Python函数之 ceil, floor,round
- Python floor() 函数
- python int() round() floor()函数的比较
- python int() round() floor()函数的比较
- python 内建函数range/math.ceil/math.floor
- python int() round() floor()函数的比较
- python内建函数
- 我与python约个会:13编程进阶~函数
- python 函数
- python简单的函数定义和用法实例
- python map, reduce, filter 函数
- python 特殊函数
- python 函数
- python常用函数(一)
- Python入门第13课——认识函数(只读课堂)
- Python与 PHP使用递归建立多层目录函数
- Python中函数partial的应用
- python 之装饰器(用装饰器给现有函数增加新功能)
- Python学习之函数
- Python——类、实例和其他对象的内建函数