and-or
在一个bool and a or b语句中,当bool条件为真时,结果是a;当bool条件为假时,结果是b。
在线运行演示代码
参考教程
a = 3 result = (a > 0) and "big" or "small" print(result) a = 0 b = 17 c = True and a or b d = (True and [a] or [b])[0] print(c, d)