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)