Python 3.x Pygame类型错误:';int';对象不可调用

Python 3.x Pygame类型错误:';int';对象不可调用,python-3.x,pygame,typeerror,Python 3.x,Pygame,Typeerror,这几行python 3.2代码使用最新的pygame模块移动图像。它与此示例相关: 这是我的密码: import pygame import sys pygame.init() screen = pygame.display.set_mode((600,400)) bg = pygame.image.load('bg.jpg') player = pygame.image.load('player.jpg') pos = player.get_rect() while True:

这几行python 3.2代码使用最新的pygame模块移动图像。它与此示例相关:

这是我的密码:

import pygame
import sys 

pygame.init()
screen = pygame.display.set_mode((600,400))
bg = pygame.image.load('bg.jpg')
player = pygame.image.load('player.jpg')
pos = player.get_rect()

while True:
    for i in pygame.event.get():
       if i.type() == pygame.QUIT:
            sys.exit()
    screen.blit(bg,(0,0))
    screen.blit(player,(i,i))
    pygame.display.update()
下面是我在运行它时遇到的错误:

回溯(最近一次呼叫最后一次):
文件“C:/Users/Willy/Desktop/Python Code/test.py”,第12行,在
如果i.type()==pygame.QUIT:
TypeError:“int”对象不可调用

我发现了类似的问题,但答案表明问题也在于使用函数名作为变量,这不是我正在做的。我似乎不知道这里出了什么问题。

应该是:

if i.type == pygame.QUIT:
而不是:

if i.type() == pygame.QUIT:
由于
事件
类的
类型
成员不是函数,因此您不需要/可以使用
()
调用它