if a != None:

>>> x = 1
>>> not x
False
>>> x = [1]
>>> not x
False
>>> x = 0
>>> not x
True
>>> x = [0]     # You don't want to fall in this one.
>>> not x
False
 
在python中 None, False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()都相当于False ,即:
not None == not False == not '' == not 0 == not [] == not {} == not ()

 if a != None:
其意思是a!=none,则执行:后面的语句
posted @ 2019-06-27 08:59  浮沉沉浮  阅读(673)  评论(0编辑  收藏  举报