Python/ref math isfinite
来自菜鸟教程
<languages />
Python math.isfinite()方法
例
检查值是否有限:
# Import math Library
import math
# Check whether the values are
finite or not
print(math.isfinite(2000))
print(math.isfinite(-45.34))
print(math.isfinite(+45.34))
print(math.isfinite(math.inf))
print(math.isfinite(float("nan")))
print(math.isfinite(float("inf")))
print(math.isfinite(float("-inf")))
print(math.isfinite(-math.inf))
print(math.isfinite(0.0))
定义和用法
The
math.isfinite()
方法检查数字是否为有限。
如果指定的数字是有限数字,则此方法返回True,否则返回False。
句法
math.isfinite(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 需要。要检查的值。必须为数字(浮点数/整数/无限/ NaN /有限) |
技术细节
| 返回值: | A
|
| Python版本: | Python 3.2的新功能 |