str1 = ""
str2 = None
str3 = "hello"

if str2:
    print "not null"
else:
    print "null"

 

这样,不仅可以判定字符串是否为空,还能判定是否为None

相关文章:

  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2021-07-24
  • 2022-12-23
  • 2021-12-04
  • 2021-12-04
相关资源
相似解决方案