python判断字符为空


# 方法1 用len

if len(string) == 0:
    # 字符串为空
else:
    # 字符串不为空
    
    
# 方法2 用not

if not string:
    # 字符串为空
else:
    # 字符串不为空