How to check if the string is empty?

后端 未结 25 1845
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 14:47

Does Python have something like an empty string variable where you can do:

if myString == string.empty:

Regardless, what\'s the most elegan

25条回答
  •  旧时难觅i
    2020-11-22 15:16

    How about this? Perhaps it's not "the most elegant", but it seems pretty complete and clear:

    if (s is None) or (str(s).strip()==""): // STRING s IS "EMPTY"...
    

提交回复
热议问题