TypeError:'int'对象不可调用(Mac)

时间:2015-03-24 21:02:47

标签: python macos pygame

我在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()

1 个答案:

答案 0 :(得分:3)

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

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