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)
标签:None,变量,python,print,isinstance,type,NoneType,name 来源: https://www.cnblogs.com/ljf520hj/p/15627619.html