pytho本身并未提供switch语句,但可以通过dict来模拟switch, #方法1 def add(x,y): return x+y def dec(x,y): return x-y def multi(x,y): return x*y def div(x,y): return x/y operater = {'+':add,'-':dec,'*':multi,'/':div} def calculator(x,o,y): return operater.get(o)(x,y) #方法2…