• 首页
    • 问答
      • c
      • c++
      • haskell
      • java
      • javascript
      • php
      • python
      • r
      • ruby
      • shell
      • .net
      • go
      • vb.net
      • erlang
    • 教程
    • 书籍
    • IT新闻

Python三元运算符

2018-05-31 14:21:11  

可能重复:
Python中的三元条件运算符

var foo = (test) ? "True" : "False";

这在Python中看起来像什么?

使用Python 2.7,如果这有所作为。


PEP 308增加了一个三元运算符:

foo = "True" if test else "False"

从Python 2.5开始就已经实现了


这个看起来更像原始三元:

foo=a and b or c
链接地址: http://www.djcxy.com/p/7393.html

上一篇: Python ternary operator

下一篇: equivalent of `a?b:c`

  • 相关推荐
  • is it possible to use variables in remote ssh command? 2018-07-04
  • 是否有可能在远程SSH命令中使用变量? 2018-07-04
  • Execute Bash script stored in a file over SSH 2018-07-04
  • 通过SSH执行存储在文件中的Bash脚本 2018-07-04
  • UNIX ssh script, running commands on remote server 2018-07-04
  • UNIX ssh脚本,在远程服务器上运行命令 2018-07-04
  • how to run a script file remotely using ssh 2018-07-04
  • 如何使用ssh远程运行脚本文件 2018-07-04
  • Run ssh and immediately execute command 2018-07-04
  • 运行ssh并立即执行命令 2018-07-04

友情链接