84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
print 'False' if (False) else 'True'
感觉有点类似 C/C++ 中的三目运算符。我在教程中都没有看到过相关的介绍。这是什么语法?
认证0级讲师
https://docs.python.org/2/reference/expressions.html#conditional-expressions
This is the syntax, just understand it.
That is, if (False) ? printf("False") : printf("True") in C, JAVA and other languages if A?B:C converted to python is B if A else C
https://docs.python.org/2/reference/expressions.html#conditional-expressions
This is the syntax, just understand it.
print 'False' if (False) else 'True'
That is, if (False) ? printf("False") : printf("True")
in C, JAVA and other languages if A?B:C converted to python is B if A else C