any
any
will return True
when at least one of the elements is Truthy. Read about Truth Value Testing.
all
all
will return True
only when all the elements are Truthy.
Truth table
+-----------------------------------------+---------+---------+
| | any | all |
+-----------------------------------------+---------+---------+
| All Truthy values | True | True |
+-----------------------------------------+---------+---------+
| All Falsy values | False | False |
+-----------------------------------------+---------+---------+
| One Truthy value (all others are Falsy) | True | False |
+-----------------------------------------+---------+---------+
| One Falsy value (all others are Truthy) | True | False |
+-----------------------------------------+---------+---------+
| Empty Iterable | False | True |
+-----------------------------------------+---------+---------+
------------------ 分割线结束 -----------------
用自己的话总结下来,就是:
any:至少一个成员为真时返回True,否则返回False,因此空参数返回False;
all:全部成员都不为假时返回True,否则返回False,因此空参数返回True。