python如何判断字符串为空

2025-06-23 06:36:06
推荐回答(2个)
回答1:

a=''
if not a:
print "a是空的"
输出结果为:a是空的

回答2:

if not str.strip():
print '字符串为空'