语法格式:条件成立时要返回的值 if 条件 else 条件不成立时要返回的值
x = 1
y = 2
res = x if x > y else y
print(res)
res = 11111 if 'allen' == 'allen' else 22222
print(res)
语法格式:条件成立时要返回的值 if 条件 else 条件不成立时要返回的值
x = 1
y = 2
res = x if x > y else y
print(res)
res = 11111 if 'allen' == 'allen' else 22222
print(res)