【发布时间】:2011-07-30 06:12:50
【问题描述】:
我之前在 python 2.7 中使用过 Pygame,但最近我“升级”到了 python 3.2。我下载并安装了最新版本的 Pygame,据说可以与这个版本的 python 一起使用。然而,我在应该是一个简单的代码块上遇到了这个相当令人沮丧的错误。代码是:
import pygame, random
title = "Hello!"
width = 640
height = 400
pygame.init()
screen = pygame.display.set_mode((width, height))
running = True
clock = pygame.time.Clock()
pygame.display.set_caption(title)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.quit():
running = False
else:
print(event.type)
clock.tick(240)
pygame.quit()
我每次运行它都会得到:
17
1
4
Traceback (most recent call last):
File "C:/Users/David/Desktop/hjdfhksdf.py", line 15, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized
为什么会出现这个错误?
【问题讨论】: