python中any,all函数

any

any(iterable, /)
    Return True if bool(x) is True for any x in the iterable.

    If the iterable is empty, return False.

函数接收一个可迭代对象, 判断该对象中每一个元素的值, 返回bool值.

如果对象中每个元素都为假(0, ”, [], (), {}, False这几种情况为假), 则返回False.

否则返回True.


all

all(iterable, /)
    Return True if bool(x) is True for all values x in the iterable.

    If the iterable is empty, return True.

函数接收一个可迭代对象, 判断该对象中每一个元素的值, 返回bool值.

如果对象中每个元素都为真(0, ”, [], (), {}, False这几种情况为假), 则返回True.

否则返回False.


猜你喜欢

转载自blog.csdn.net/One_of_them/article/details/82657225