更换开关声明

时间:2018-04-04 19:18:15

标签: python

我有以下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语句,但我很好奇是否有更好的方法来编写它。顺便说一下,移动只是一个布尔

0 个答案:

没有答案