Python's any () and all () usage

usage

any(x):

  • X is determined whether the object is an empty object, if are empty, 0, false, false is returned, are not true if null, 0, false

all(x):

  • If all of the elements All (x) is not an object parameter x 0, '', False or x is an empty object, then return True, False otherwise

Precautions

 print(all([]))    # 空列表
 print(all(()))    # 空元组

Namely: empty tuple, an empty list is returned values ​​are True

Published 378 original articles · won praise 43 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_43283397/article/details/105137266