📜  Python – cmath.isfinite()函数

📅  最后修改于: 2022-05-13 01:54:18.549000             🧑  作者: Mango

Python – cmath.isfinite()函数

cMath 模块包含许多用于复数数学运算的函数。 cmath.isfinite()函数用于检查值是否有限。此函数中传递的值可以是int、float复数

下面的例子说明了上述函数的使用:

示例 #1:

Python3
# Python code to implement
# the isfinite()function
        
# importing "cmath"
# for mathematical operations  
import cmath 
    
# using cmath.isfinite() method 
val = cmath.isfinite(1 + 2j) 
print(val)


Python3
# Python code to implement
# the isfinite()function
        
# importing "cmath"
# for mathematical operations  
import cmath 
    
# using cmath.isfinite() method 
val = cmath.isfinite(complex(3.0, float('inf')))
print(val)


输出:

True

示例 2:

Python3

# Python code to implement
# the isfinite()function
        
# importing "cmath"
# for mathematical operations  
import cmath 
    
# using cmath.isfinite() method 
val = cmath.isfinite(complex(3.0, float('inf')))
print(val)

输出:

False