pygame无法加载imag

2024-06-28 19:35:07 发布

您现在位置:Python中文网/ 问答频道 /正文

import pygame, sys
from pygame.locals import *

pygame.init()
window = pygame.display.set_mode((400, 300))

my_image = pygame.image.load(r'/Users/Humberto/documents/python/games/alien')
posX, posY = 200, 150

window.blit(my_image, (posX, PosY))


while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()


    pygame.display.update()

我试图加载在同一个文件夹中的图像,它将返回一个错误消息pygame.error.错误:无法打开/Users/Humberto/documents/python/games/alien我尝试过编写.png扩展名,也使用/和//编写整个路径,还尝试了原始字符串。我怎样才能解决这个问题?在


Tags: imageimporteventmy错误displaysyswindow