Python/ref math isinf
来自菜鸟教程
<languages />
Python math.isinf()方法
例
检查值是否为无穷大:
# Import math Library
import math
# Check whether the values are
infinite or not
print(math.isinf(56))
print(math.isinf(-45.34))
print(math.isinf(+45.34))
print(math.isinf(math.inf))
print(math.isinf(float("nan")))
print(math.isinf(float("inf")))
print(math.isinf(float("-inf")))
print(math.isinf(-math.inf))
定义和用法
The
math.isinf()
方法检查数字是否为无穷大。
如果指定的数字为正或负无穷大,则此方法返回True,否则返回False。
句法
math.isinf(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 需要。检查号码 |
技术细节
| 返回值: | A
|
| Python版本: | 2.6 |