(skill) 在 if 后,python将非空字符串解读为True.
例子:
>>> a='1'
>>> if a:
... print("not empty")
... else:
... print("empty")
...
not empty
>>>
>>> a=''
>>> if a:
... print("not empty")
... else:
... print("empty")
...
empty
(skill) 在 if 后,python将非空字符串解读为True.
例子:
>>> a='1'
>>> if a:
... print("not empty")
... else:
... print("empty")
...
not empty
>>>
>>> a=''
>>> if a:
... print("not empty")
... else:
... print("empty")
...
empty