【发布时间】:2010-09-16 12:35:56
【问题描述】:
我在 SO 上遇到了Python: What is the best way to check if a list is empty? 的问题。
现在,如果我想返回 True (False),具体取决于集合 coll 在函数中是否为非空(空),那么推荐的方法是什么? return not not coll?
【问题讨论】:
标签: python collections
我在 SO 上遇到了Python: What is the best way to check if a list is empty? 的问题。
现在,如果我想返回 True (False),具体取决于集合 coll 在函数中是否为非空(空),那么推荐的方法是什么? return not not coll?
【问题讨论】:
标签: python collections
你可以使用
return bool(coll)
【讨论】: