💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
* 作者:煮酒品茶 tea * 博客:http://www.zwhset.com http://cwtea.blog.51cto.com * 目前在京峰教育担任python讲师 #1、函数原型 > 只要有一个对象为真则为真,相对应的有all函数 ~~~ any(...) any(iterable) -> bool 只要有一个对象为真则为真, for x in iterable 如果bool(x)为真则返回真, Return True if bool(x) is True for any x in the iterable. If the iterable is empty, return False. 样例代码 def any(iterable): for x in iterable: if x: return True return False ~~~ #2、样例 ~~~ In [11]: any([]) Out[11]: False In [12]: any([1,2]) Out[12]: True In [13]: any([1,2,0]) Out[13]: True In [14]: any(["",0,0]) Out[14]: False ~~~