Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 属性错误:模块';pygame.event';没有属性';类型';_Python 3.x - Fatal编程技术网

Python 3.x 属性错误:模块';pygame.event';没有属性';类型';

Python 3.x 属性错误:模块';pygame.event';没有属性';类型';,python-3.x,Python 3.x,我正在从“编写此游戏代码”学习python,在第一次尝试时遇到了一个错误: AttributeError:模块“pygame.event”没有属性“type” 源代码如下: import pygame from pygame import * pygame.init() WINDOW_WIDTH = 900 WINDOW_HEIGHT = 400 WINDOW_RES = (WINDOW_WIDTH, WINDOW_HEIGHT) GAME_WINDOW = display.set_mode(W

我正在从“编写此游戏代码”学习python,在第一次尝试时遇到了一个错误:

AttributeError:模块“pygame.event”没有属性“type”

源代码如下:

import pygame
from pygame import *
pygame.init()
WINDOW_WIDTH = 900
WINDOW_HEIGHT = 400
WINDOW_RES = (WINDOW_WIDTH, WINDOW_HEIGHT)
GAME_WINDOW = display.set_mode(WINDOW_RES)
display.set_caption('Attack of the Vampire Pizzas!')
game_running = True
while game_running:
    for events in pygame.event.get():
        if event.type == QUIT:
            game_running = False

    display.update()
pygame.quit()
谢谢!! DK

您必须编辑“
事件.类型”
”到“
事件.类型”

if events.type == QUIT: