TypeError: 'int' object is not callable (Mac)

TypeError: 'int' object is not callable (Mac)

我在 mac 上使用 python 3.4.3。我是用自制软件安装的,所以我不确定它是我的代码还是我需要重新安装。

这是我得到的错误:

File "~/Documents/python game/main/main.py", line 16, in ?
if Event.type == pygame.QUIT():
TypeError: 'int' object is not callable

这是我的代码:

import pygame

pygame.init()

gameDisplay = pygame.display.set_mode ((800, 600))

pygame.display.set_caption('game')

clock = pygame.time.Clock()

running = True

while running:

for Event in pygame.event.get():
    if Event.type == pygame.QUIT():
        running = False
    print(Event)

pygame.display.update()

clock.tick(30)

pygame.quit()
quit()

您的错误是您调用了 pygame.QUIT。或者,pygame.QUIT 是一个数字。所以你得到一个错误。 你必须这样做:

...
if Event.type == pygame.QUIT:
    ...