#Python 的内置函数 any
说明:判断可迭代对象内容是否存在真值。
#函数说明
def any(iterable):
'''
判断可迭代对象内容是否存在真值
:param iterable: 一个可迭代对象
:return: 如果 iterable 中存在真值则返回 True,否则返回 False;如果 iterable 是空的,返回 False
'''
说明
判断可迭代对象内容是否 存在 真值,空的可迭代对象不存在真值。
参数
iterable
- 一个可迭代对象
返回值
- 如果
iterable
存在真值,则返回True
- 如果
iterable
全部是假值,否则返回False
- 如果
iterable
是空的,返回False
#示例
print(any([])) # 空的可迭代对象返回 False
print(any(range(10))) # 0...9
print(any([0 for _ in range(0)])) # 0...0