python学习笔记——三元操作符

三元操作符

三元操作符的基本格式为:

result = x if x < y else y

其中,x < y 为判断语句。若 x < y 为真则 result = x,否则 result = y。

你可能感兴趣的:(python)