1、Python 中使用 if、elif、else 来进行基础的条件选择操作:
1 2 3 4 5 6 7 |
|
2、Python 同样支持 ternary conditional operator,也可以使用 Tuple 来实现类似的效果:
1 2 3 4 5 6 7 8 |
|
以上就是python实现条件选择的方法,希望对大家有所帮助。更多Python学习指路:python基础教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
1、Python 中使用 if、elif、else 来进行基础的条件选择操作:
1 2 3 4 5 6 7 |
|
2、Python 同样支持 ternary conditional operator,也可以使用 Tuple 来实现类似的效果:
1 2 3 4 5 6 7 8 |
|
以上就是python实现条件选择的方法,希望对大家有所帮助。更多Python学习指路:python基础教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
© 2021 Python学习网 苏ICP备2021003149号-1