标签: python list-comprehension
我们可以在列表理解中创建多个“ if”过滤器:
>>> xs = [1,2,3] >>> [x for x in xs if x < 3 if x < 2] [1]
它们支持短路:
>>> [x for x in xs if x > 4 if this-makes-no-Error] []
为什么在语法中允许这样做?用逻辑运算符不能更清楚地完成什么用例?