一般C系列语言,例如C#,三目运算都是“ ?:”的结构。
例如:
res = (i > j ? true : false);
但是在python中,使用的是if-else来实现的
res = True if i > j else 2;
如果条件为真的话,那么结果为前者,否则为后者
【转载于自己的CSDN博客】原链接:https://blog.csdn.net/Mister_Feng/article/details/52728743
一般C系列语言,例如C#,三目运算都是“ ?:”的结构。
例如:
res = (i > j ? true : false);
但是在python中,使用的是if-else来实现的
res = True if i > j else 2;
【转载于自己的CSDN博客】原链接:https://blog.csdn.net/Mister_Feng/article/details/52728743