您的位置:首页 > 编程语言 > Python开发

python any all函数

2015-10-08 17:22 465 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: