python判断变量是否为None

name = None
print(name,type(name))
#判断变量是否 None 不能用type和isinstance
# print(isinstance(name,NoneType))
# print(type(name)==NoneType)
# print(isinstance(name,'NoneType'))
# print(type(name)=='NoneType')
#用is 判断 NoneType类型  不行
# print(type(name) is 'NoneType')
print(name is None)
print(name is not None)

 

上一篇:notebook 显示图片、训练过程可视化


下一篇:css的布局