我有以下python代码:
if direction == 0: # Left
moved = self.slideLeft()
elif direction == 1: # Right
moved = self.slideRigth()
elif direction == 2: # Up
moved = self.slideUp()
elif direction == 3: # Down
moved = self.slideDown()
if(moved):
我知道python中没有swith语句,但我很好奇是否有更好的方法来编写它。顺便说一下,移动只是一个布尔