Python确实具有elvis运算符。它是条件or
运算符:
x = f() or g()
f()
被评估。如果为真,则为x分配值f()
,否则为x分配值g()
。
参考:https ://en.wikipedia.org/wiki/Elvis_operator#Analogous_use_of_the_short- circuiting_OR_operator
Python是否具有Elvis运算符?
Python确实具有elvis运算符。它是条件or
运算符:
x = f() or g()
f()
被评估。如果为真,则为x分配值f()
,否则为x分配值g()
。
参考:https ://en.wikipedia.org/wiki/Elvis_operator#Analogous_use_of_the_short- circuiting_OR_operator