Python 版 switch 尝鲜
資深大佬 : ChrisFreeMan 92
def handle_input(self, key_event: event.Event) -> None: for menu in self.menus: menu.handle_input(key_event) if key_event.type == pygame.KEYDOWN: match key_event.key: case pygame.K_w | pygame.K_UP: self.select_menu_key -= 1 if self.select_menu_key < 0: self.select_menu_key = 0 self._key_menu_select_handle() case pygame.K_s | pygame.K_DOWN: self.select_menu_key += 1 if self.select_menu_key > len(self.menus) -1: self.select_menu_key = len(self.menus) -1 self._key_menu_select_handle()
我的 vim 配色还没发识别这个最新的语法
大佬有話說 (18)