我是 python (3.6) 的新手,我写道:
def foo(alist, blist):
if alist or blist:
return alist or blist
print(foo([2], []))
打印[2]
。
而且我试图理解:似乎一个列表被评估为False
\ True
,if alist or blist
但在return alist or blist
它返回列表本身而不是False
\ True
。怎么样?
是否alist or blist
对两者的非空列表求值?文档中是否有针对所有这些内容编写的规则?
谢谢
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句