【问题标题】:How to fix this error occurred while using .png image in visual studio code?如何解决在 Visual Studio 代码中使用 .png 图像时发生的此错误?
【发布时间】:2020-11-13 16:08:19
【问题描述】:

如您所见,我正在尝试在我的程序中添加 .png 图像,但是当我尝试时它显示错误

解释器显示以下错误-

加载图片时出错

使用 VS 代码的标准文本/二进制/编辑器打开文件?

 import pygame

 #initialize pygame

 pygame.init()


 #create the game screen

 screen = pygame.display.set_mode((800,600))


 # title and icon

 pygame.display.set_caption("space invaders")

 icon = pygame.image.load('spaceship.png')

 pygame.display.set_icon(icon)



# game loop

running = True

while running:

for event in pygame.event.get():

 if event.type == pygame.QUIT:

 running = False

【问题讨论】:

    标签: python python-3.x


    【解决方案1】:

    不幸的是,它是known and reported bug on the official repo of VS Code。我邀请您阅读 cmets,但不幸的是,该问题已关闭,似乎没有明确的解决方案。有人声称它不会一直发生,并且通过重新启动 VS Code 就不会遇到错误。

    这里可以看到已经被举报了好几次了:

    【讨论】:

      猜你喜欢
      • 2010-10-31
      • 2021-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      相关资源
      最近更新 更多