我正在尝试在python 2.7.5中运行以下程序
import pygame ,sys
pygame.init()
pygame_events = pygame.event.get()
screen = pygame.display.set_mode([640, 480])
screen.fill([255,255,255])
pygame.draw.circle(screen, [255, 0, 0],[100, 100], 30 ,0)
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.get == pygame.QUIT:
running = False
pygame.quit()
但是,它不起作用,我收到以下错误消息
Traceback (most recent call last):
File "C:\Python27\tanks\tanks_progam.py", line 10, in <module>
if event.get == pygame.QUIT:
AttributeError: 'Event' object has no attribute 'get'
有人可以帮我解决问题吗?
答案 0 :(得分:1)
应该是type
而不是get
:
if event.type == pygame.QUIT: