检查列表为空的最好办法

用隐藏的空列表的布尔值才是最 Pythonic 的方法:

if not a:
    print("list a is empty")

虽然我自己一般用 len(a) == 0

Last updated