码迷,mamicode.com
首页 > 编程语言 > 详细

python any and all function

时间:2017-09-24 23:25:14      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:rabl   none   utils   class   iterable   htm   span   function   ppi   

1 any

如果iterable object至少有一个元素是true的时候,返回为true。空的iterable object返回为false。

2 all

如果iterable object中的每个元素都是true的时候返回true,空的iterable object也返回true。

3 什么叫iterable object的元素是true

python的所有对象都是有true和false的。满足下面条件的object是false,其余的都是true。

  • None

  • False

  • zero of any numeric type, for example, 0, 0L, 0.0, 0j.

  • any empty sequence, for example, ‘‘, (), [].

  • any empty mapping, for example, {}.

  • instances of user-defined classes, if the class defines a __nonzero__() or __len__() method, when that method returns the integer zero or bool value False. [1]

python any and all function

标签:rabl   none   utils   class   iterable   htm   span   function   ppi   

原文地址:http://www.cnblogs.com/hustdc/p/7531577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!