【发布时间】:2020-04-26 18:08:00
【问题描述】:
我一直在学习 Pygame 中的图形,我试图对背景进行 blit,但是当我运行我的程序时,它给了我这个错误:
pygame.error: Couldn't open blue.png
the png and the python file are in the same folder on my desktop.
我的代码如下所示:
from os import path
background = pygame.image.load('blue.png')
background_rect = background.get_rect()
screen.blit(background, background_rect)
screen.blit(background, background_rect)
all_sprites.draw(screen)
pygame.display.flip()
screen.fill(BLACK)
【问题讨论】:
-
应该可以 - 你能仔细检查路径、文件名和文件权限吗?或者尝试图像的绝对路径?
-
谢谢,我仔细检查了路径,我忘记了文件夹