Linux 拨号vps windows公众号手机端

python nonetype怎么判断

lewis 8年前 (2017-05-05) 阅读数 9 #程序编程
文章标签 python

在Python中,可以使用type()函数来判断一个变量的类型。如果变量是None类型,即NoneTypetype()函数将返回NoneType。例如:

x = None

if type(x) == type(None):
    print("x is NoneType")
else:
    print("x is not NoneType")

输出结果为:

x is NoneType
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门