如何检查列表是否为空?
问题描述:
例如,如果通过以下内容:
For example, if passed the following:
a = []
如何检查a
是否为空?
答
if not a:
print("List is empty")
使用空的list
的隐式布尔值相当pythonic.
Using the implicit booleanness of the empty list
is quite pythonic.