len(s==0)则字符串为空
test1 = '' if len(test1) == 0: print('test1为空串') else: print('test非空串,test='+test1)
>>> str="" >>> print(str.isspace()) False >>> str=" " >>> print(str.isspace()) True >>> str="a " >>> print(str.isspace()) False >>>
判断字符串是否为空或者none
test1 = None if test1: print('字符串不是空也不是None') else: print('字符串是None或者空串')