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
相关文章推荐
- Python模块paramiko:操作远程服务器
- Python的执行过程
- Python subprocess模块总结
- 初学Numpy(五)
- python多线程编程基础
- 升级python、安装django
- Python print中文乱码
- Python保存时提示“SyntaxError: Non-ASCII character '\xe8' in file”
- 初学Numpy(四)
- python实现简单爬虫功能
- mac 下 升级 python
- 初学Numpy(三)
- 深度学习(九)caffe预测、特征可视化python接口调用
- python编码问题(2)
- Python的图形界面工具----PyQt
- python下很帅气的爬虫包 - Beautiful Soup 示例
- windows下python实现截图功能
- 初学Numpy(二)
- 《Python基础教程 第2版·修订版》 第2章 列表和元组(学习笔记·总)
- 搭建或者升级Python环境笔记,吐血记录!