【发布时间】:2015-01-20 06:27:51
【问题描述】:
我没有得到 python 中 if 语句的语法:
>> z=[0 if all([2<3,6<7]) else sth] #Correct
>>
>> z=[0 if all([2<3,6<7])] #Wrong
File "<stdin>", line 1
z=[0 if all([2<3,6<7])]
^
SyntaxError: invalid syntax
>>
我不知道Correct 行和Wrong 行之间的这种语法和区别?
【问题讨论】:
-
为了澄清,假设
all条件为假。您希望为z分配什么值?
标签: python if-statement syntax syntax-error