简体   繁体   中英

AttributeError: 'Event' object has no attribute 'get'

I am trying to run the following progam in 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()

However,it does not work and I get the following eror message

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'

Can anybody help me with my problem?

它应该是type not get

if event.type == pygame.QUIT:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM