共計 187 個字符,預(yù)計需要花費 1 分鐘才能閱讀完成。
在 Python 中,可以使用 type()
函數(shù)來判斷一個變量的類型。如果變量是 None
類型,即 NoneType
,type()
函數(shù)將返回NoneType
。例如:
x = None
if type(x) == type(None):
print("x is NoneType")
else:
print("x is not NoneType")
輸出結(jié)果為:
x is NoneType
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!
正文完