首页 > 解决方案 > Pygame 错误:'int' 对象不可调用

问题描述

import pygame

pygame.init()
screen = pygame.display.set_mode((800, 600))
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT(): 
            running = False

执行此代码时,我收到以下错误:

'int' object is not callable

标签: pythonpygametypeerror

解决方案


pygame.QUIT是一个int而不是一个函数。尝试删除括号:

if event.type == pygame.QUIT:
    running = False

推荐阅读