我刚刚开始学习Python / PyGame。我目前正在学习一个教程,但是每当按下一个键时都会遇到以下错误:
File "wormy.py", line 134, in checkForKeyPress
return keyUpEvents[0].keyUpEvents
AttributeError: event member not defined
有问题的实际代码是:
def checkForKeyPress():
if len(pygame.event.get(QUIT)) > 0:
terminate()
keyUpEvents = pygame.event.get(KEYUP)
if len(keyUpEvents) == 0:
return None
if keyUpEvents[0].key == K_ESCAPE:
terminate()
return keyUpEvents[0].keyUpEvents
有人可以解释我在这里做错了吗?