【发布时间】:2017-10-03 08:43:59
【问题描述】:
我在 Pycharm 中使用 Pygames 工作时遇到问题,当我尝试 pygame.image.load() 时它不起作用,并一直告诉我它在 image.py 中找不到“加载”。我重新下载了pygame包,还是不行。请帮我。
Pycharm 报告:Cannot find reference 'load' in 'image.py',使用 pygame.image.load() 时。尝试执行此命令时代码中断。
import pygame
pygame.init()
surface = pygame.display.set_mode((1200, 720))
my_image = pygame.image.load('maxresdefault.bmp')
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
surface.fill((188, 22, 22)
surface.blit(my_image, (0, 0))
pygame.display.update()
pygame.quit()
重新下载 Pygame 包后,问题依旧。
【问题讨论】:
-
Pycharm 错误警告
pygame.image.load找不到,但可以。尝试加载 png 图像,因为 pygame 只能加载有限数量的格式。 -
在Pycharm中查看image.py代码后,我发现它从另一个文件
load()导入:from pygame.imageext import load, load_extended, save_extended。在 imageext.py 中没有名为load的方法,至少 Pycharm 没有显示。 Pygame.image