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