非空即真,非零即真 如果被判断的内容为空,包括字符串、列表、字典、整数、none,则该判断为 False, 否则为True false 内容包括 a="" b=[] c={} d=0 f=None username = input("username:").strip() # if len(username) == 0: # print("输入不能为空") if username: print("username",username) else: print("username不能为空")