python字符串相等if,python判断字符串是否为空用什么方法

2024-12-17 20:44:54
推荐回答(1个)
回答1:

reaCode = Noneif ( reaCode == None ): print "is null"else : print "not!"if ( reaCode is None ): print "is null"else : print "not!"reaCode = ''if ( reaCode is '' ): print "is null string"else : print "not!"reaCode = ''if ( reaCode == '' ): print "is null string"else : print "not!"if ( reaCode == None ): print "is null"else : print "not!"if ( reaCode is None ): print "is null"else : print "not!"None是一个空的对象,代表什么都没有。而'',是一个字符串对象,代表一个空的字符串。