首页
技术
登录
6mi
u
盘
搜
搜 索
技术
python中的三目运算符
python中的三目运算符
技术
2022-07-11
77
python中的三目运算符
众所周知,在java中的三目运算符如下。
int
result
=
(
3
>
2
)
?
1
:
0
但是在python中时支持上面的写法的,得用到以下写法。
result
=
1
if
3
>
2
else
0
#优先级顺序
1
、
if
3
>
2
2
、result
=
1
|
0
转载请注明原文地址:https://ipadbbs.8miu.com/read-18708.html
最新回复
(
0
)