我没有看完整的Python学习教程,但是我正在学习如何使用pygame。我知道一些关于Python的事情,但不太了解 我现在试着放一个背景图像,教程说我必须使用这个函数:
def load_image(filename, transparent=False):
try: image = pygame.image.load(filename)
except pygame.error, message:
raise SystemExit, message
image = image.convert()
if transparent:
color = image.get_at((0,0))
image.set_colorkey(color, RLEACCEL)
return image
但是在我的编辑器(Pyscripter)中,except pygame.error, message:
有一个sintaxis错误,我不知道为什么,如果我删除它,以raise开头的行也有sintaxis错误。。。我能做什么?
提前谢谢!在
您使用的是
except
的旧语法。新方法使用as
:从Python 3.x开始,旧的方法已被删除。请参见以下内容:
^{pr2}$另外,
raise
语句的语法错误。它应该是:见下文:
最后的代码应该是这样的:
相关问题 更多 >
编程相关推荐