Python cmath.isinf() 方法
实例
检查复数是否为无穷大:
#import cmath for complex number operations
import cmath
#find
whether a complex number is infinite or not
print (cmath.isinf(complex(10
+ float('inf'))))
print (cmath.isinf(11 + 4j))
亲自试一试 »
定义和用法
cmath.isinf() 方法检查一个值是正无穷还是负无穷。 此方法返回一个布尔值:如果值为无穷大,则返回 True,否则返回 False。
语法
cmath.isinf(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 必需。检查无穷大的值 |
技术细节
| 返回值: | 一个 bool 值,如果该值是无穷大,则 True,否则 错误 |
|---|---|
| Python 版本: | 2.6 |

