我有两个for循环:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
quit()
if event.type == KEYDOWN:
if event.key == K_p:
banana = False
sportscar = True
for event in pygame.event.get:
if event.type == QUIT:
pygame.quit()
quit()
每当我运行我的代码时,都会收到此错误:
Traceback (most recent call last):
File "D:\Calorie Calculator v2.py", line 43, in <module>
if event.type == QUIT:
NameError: name 'QUIT' is not defined
我不知道为什么会这样做,因为在它完美运作之前。
答案 0 :(得分:3)
将if event.type == QUIT:
更改为event.type == pygame.QUIT: