python中非空即真,非0即真

True: "1"  [1] {k-v}

False: None [] {}

username = input("username:").strip()
if username:
print("username不为空")
else:
print("username为空")

 

posted on 2018-11-27 20:12  徐儿  阅读(93)  评论(0编辑  收藏  举报