For example, if passed the following:
a = []
How do I check to see if a
is empty?
转载于:https://stackoverflow.com/questions/53513/how-do-i-check-if-a-list-is-empty
For example, if passed the following:
a = []
How do I check to see if a
is empty?
转载于:https://stackoverflow.com/questions/53513/how-do-i-check-if-a-list-is-empty
if not a:
print("List is empty")
Using the implicit booleanness of the empty list is quite pythonic.