Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 397 Bytes

12.md

File metadata and controls

24 lines (16 loc) · 397 Bytes
rank vote view answer url
12 2862 1856471 30 url

检查列表是否为空的最好方法

例如,传递下面:

a = []

我怎么检查a是空值?


if not a:
  print "List is empty"

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