shanghaipc 发表于 2018-8-13 10:44:44

python 基础之三元运算

name = "hello" if 2> 1 else "world"  
print name
  
# 如果条件满足,则吧hello赋值给name,如果条件不满足,则吧world赋给name
页: [1]
查看完整版本: python 基础之三元运算