您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python是否具有Elvis运算符?

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

python 2022/1/1 18:42:15 有273人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶