【问题标题】:AttributeError: 'Event' object has no attribute 'get'AttributeError:“事件”对象没有属性“获取”
【发布时间】:2017-09-03 14:28:31
【问题描述】:

我正在尝试在 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'

谁能帮我解决我的问题?

【问题讨论】:

    标签: python python-2.7 pygame


    【解决方案1】:

    应该是type 而不是get

    if event.type == pygame.QUIT:
    

    【讨论】:

      猜你喜欢
      • 2019-12-17
      • 2019-08-25
      • 1970-01-01
      • 2019-06-03
      • 2015-02-17
      • 2020-12-18
      • 2013-11-06
      • 2021-03-17
      • 1970-01-01
      相关资源
      最近更新 更多