def all(*args, **kwargs):
    """
    Return True if bool(x) is True for all values x in the iterable.

    If the iterable is empty, return True.
    """

例:

print(all([1, 2, 3, 0]))   # False
print(all([1, 2, 3]))      # True
print(all([1, 2, 3, '']))  # False
print(all(''))             # True

any

def any(*args, **kwargs):
    """
    Return True if bool(x) is True for any x in the iterable.

    If the iterable is empty, return False.
    """

例:

print(any([0, '']))        # False
print(any([1, 2, 3]))      # True
print(any([1, 2, 3, '']))  # True
print(any(''))             # False

  

随机推荐

  1. 学会简单使用log4j

    简单配置: ### ??Logger?????????? ### ##log4j.rootLogger=debug, stdout,logfile log4j.rootLogger=debug, st ...

  2. 51nod 最长递增子序列

    nlogn版最长递增子序列.线段树.(其实常数蛮大的....) #include<iostream> #include<cstring> #include<algorit ...

  3. 【Python】菜鸟的基本课程继续中

    同样的缩进表示这段代码处于同一个层次. 每一个print都自带一个换行. 定义变量一定要在使用函数等之前. abs(-14) ======= 取绝对值函数 内建函数 print abs(-14) == ...

  4. HDU 3183 A Magic Lamp

    直接模拟   如果后一位比前一位小,那就一直 向前 pop()掉 维护他单调递增: #include<iostream> #include<cstring> #include& ...

  5. PPTP模式跟L2TP模式有什么不同

    使用VPN的时候经常会看到商家说支持PPTP模式和L2TP模式,但是许多朋友都不知道有什么区别,该用哪一个,下面给你们讲讲: 1).PPTP协议是点对点隧道协议:其将控制包与数据包分开,控制包采用TC ...

  6. ADG打补丁

    1 产品DG备库安装 16494615 补丁 主库停止向备库传输日志 alter system set log_archive_dest_state_2=defer; alter system set ...

  7. unity, 在保持场景根节点Transform不变且Hierarchy结构不变的前提下整体旋转场景

    比如我们摆出下面结构: 其Hierarchy如下: 其中根节点road的Transform是如下干净的原始状态: 现在想保持road的Hierarchy和Transform都不变的情况下将road旋转 ...

  8. background-size background-positon合并的写法

    background:url('../../image/banner/banner1.jpg') #fff no-repeat 5px center/50px 50px; "/"前 ...

  9. 【转】VMware 11安装Mac OS X 10.10

    VM11安装Mac OS X 10.10 网上竟没有搜到相似的内容,所以拿出来大家分享 工具/原料 1.VMware Workstation 11 2.unlocker 203(for OS X 插件 ...

  10. hibernate的组成部分

    持久化类 实现对应的序列化接口 必须有默认的构造函数 持久化类的属性不能使用关键字 标示符 映射文件 类型 java类型和hibernate类型 主键的产生器 increment identity a ...