-2

我正在尝试创建一个函数来加载我的图像但每次我运行它都会返回“无法加载图像”

def load_image(file_name, colorkey = None):

  full_name = os.path.join('data', file_name)

  try:
    image = pygame.image.load(full_name)
 except pygame.error, message:
    print 'Cannot load image:', full_name
    raise SystemExit, message

    image = image.convert()

  if colorkey is not None:
   if colorkey is -1:
    colorkey = image.get_at((0,0))
    image.set_colorkey(colorkey, RLEACCEL)

  return image,image.get()
4

1 回答 1

0

如果您在 Windows 上,则需要执行以下操作:

os.path.join('c:%s' % os.sep, 'data')
于 2012-12-17T16:21:06.333 回答