Python cmath.isnan()วิธี การ
ตัวอย่าง
ตรวจสอบว่าค่าที่ซับซ้อนเป็น NaN หรือไม่:
#import cmath for complex number operations
import cmath
#find
whether a complex number is NaN or not
print (cmath.isnan(12 +
float('nan')))
print (cmath.isnan(2 + 3j))
ความหมายและการใช้งาน
วิธี การcmath.isnan()
ตรวจสอบว่าค่าเป็นน่าน (ไม่ใช่ตัวเลข) หรือไม่ เมธอดนี้คืนค่าบูลีน: True
หากค่าเป็น nan มิฉะนั้นFalse
ไวยากรณ์
cmath.isnan(x)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
x | Required. The value to check for NaN |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่า ถ้า bool ส่วนTrue ใดส่วนหนึ่ง (จำนวนจริงหรือจินตภาพ) ของจำนวนเชิงซ้อนเป็น NaN มิฉะนั้นFalse |
---|---|
เวอร์ชันหลาม: | 2.6 |