Python/条件表达式
外观
< Python
条件语句:
if condition_1:
statement_block_1
elif condition_2:
statement_block_2
else:
statement_block_3
Python没有switch语句,一种办法是:
result = {
'a': lambda x: x * 5,
'b': lambda x: x + 7,
'c': lambda x: x - 2
}[value](x)