-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 に答える