涛子 - 简单就是美

成单纯魁增,永继振国兴,克复宗清政,广开家必升

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
a = [0, 0, 0, 0]
b = [0, 0, 0, 1]
c = [1, 1, 1, 1]
>>> any(a)
False

>>> any(b)
True

>>> any(c)
True

Return True if bool(x) is True for any x in the iterable.If the iterable is empty, return False.
当传入空可迭代对象时返回False,当可迭代对象中有任意一个为true,则返回True

>>> all(a)
False

>>> all(b)
False

>>> all(c)
True

Return True if bool(x) is True for all values x in the iterable.If the iterable is empty, return True.
当传入空可迭代对象时返回True,当可迭代对象中有任意一个不为True,则返回False

posted on 2015-10-08 17:22  北京涛子  阅读(222)  评论(0编辑  收藏  举报