Python cmath.inf() 方法

定义和用法

cmath.inf 常量返回浮点型正无穷大值。

对于负无穷大,请使用 -cmath.inf

cmath.inf 常量相当于 float("inf")

实例

打印正无穷大和负无穷大:

# 导入 cmath 库  
import cmath   
  
# 打印正无穷大  
print (cmath.inf)  
  
# 打印负无穷大  
print (-cmath.inf)

亲自试一试

语法

cmath.inf

技术细节

返回值: 浮点数值,代表正无穷大的值。
Python 版本: 3.6