python - 我们可以在 Python 中链接三元运算符吗?
问题描述
我们可以在 Python 中链接三元运算符吗?我们可以if
在 Java 中针对多个条件执行此操作。这也可以在 Python 中完成吗?
解决方案
是的。
x = 'x' if 1<0 else 'y' if 0<1 else 'z'
推荐阅读
- android - Android Studio 模拟器会影响 Firestore 登录吗?
- c++ - 如何去掉小数点后的这些 0?
- python - Python函数的多个返回值?
- python - PyQt5 gui设置保存
- firebase - Firebase 功能 - 添加的新功能不允许运行
- javascript - How do I determine a winner in Tic Tac Toe
- xlib - 如何正确调用 XWindows.XGetImage?
- wordpress - 如何使用 elementor 插件小部件将文章添加到 WordPress?
- javascript - Puppeteer 不在页面中执行匿名函数
- python - 使用 python 在 Gmail 中发送邮件