Python 中的 floor(x)函数

首页 / Python2入门教程 / Python 中的 floor(x)函数

Python Floor()返回x的Floor-不大于x的最大整数。

floor(x) - 语法

import math

math.floor( x )
  • x  -  数值表达式。

floor(x) - 返回值

此方法返回不大于x的最大整数。

无涯教程网

floor(x) - 示例

以下示例显示Floor()方法的用法。

#!/usr/bin/python
import math   # This will import math module

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)

当无涯教程运行上面的程序时,它产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/python/number-floor.html

来源:LearnFk无涯教程网

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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

玩转Spring全家桶 -〔丁雪丰〕

玩转webpack -〔程柳锋〕

雷蓓蓓的项目管理实战课 -〔雷蓓蓓〕

后端存储实战课 -〔李玥〕

WebAssembly入门课 -〔于航〕

技术面试官识人手册 -〔熊燚(四火)〕

如何成为学习高手 -〔高冷冷〕

云计算的必修小课 -〔吕蕴偲〕

结构学习力 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)