首页 > 解决方案 > 我们可以在 Python 中链接三元运算符吗?

问题描述

我们可以在 Python 中链接三元运算符吗?我们可以if在 Java 中针对多个条件执行此操作。这也可以在 Python 中完成吗?

标签: pythonconditional-operator

解决方案


是的。

x = 'x' if 1<0 else 'y' if 0<1 else 'z'

推荐阅读