numpy.isdtype#

numpy.isdtype(dtype, kind)[原始碼]#

判斷提供的 dtype 是否為指定的資料型別 kind

此函數僅支援內建的 NumPy 資料型別。尚不支援第三方 dtype。

參數:
dtypedtype

輸入 dtype。

kinddtype 或 str 或 dtype/str 的元組。

dtype 或 dtype 種類。允許的 dtype 種類為:* 'bool' : 布林種類 * 'signed integer' : 帶號整數資料型別 * 'unsigned integer' : 無號整數資料型別 * 'integral' : 整數資料型別 * 'real floating' : 實值浮點資料型別 * 'complex floating' : 複數浮點資料型別 * 'numeric' : 數值資料型別

傳回值:
outbool

另請參閱

issubdtype

範例

>>> import numpy as np
>>> np.isdtype(np.float32, np.float64)
False
>>> np.isdtype(np.float32, "real floating")
True
>>> np.isdtype(np.complex128, ("real floating", "complex floating"))
True