Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法打开image.png_Python_Pygame - Fatal编程技术网

Python 无法打开image.png

Python 无法打开image.png,python,pygame,Python,Pygame,我试图创建一个太空入侵者游戏,但它无法打开图像 这是密码 import pygame # Inizialize the pygame pygame.init() #create the screen screen = pygame.display.set_mode((800, 600)) # Title and Icon pygame.display.set_caption('Space Invaders') #Player playerImg = pygame.image.loa

我试图创建一个太空入侵者游戏,但它无法打开图像 这是密码

import pygame

# Inizialize the pygame
pygame.init()

#create the screen
screen = pygame.display.set_mode((800, 600))

# Title and Icon
pygame.display.set_caption('Space Invaders')
   
#Player
playerImg = pygame.image.load('space-invaders.png')
playerX = 370
playerY = 480

def player():
    screen.blit(playerImg, (playerX, playerY))

#Game Loop
running = True
while running:

    #RGB - red, green and blue
    screen.fill((0,0,0))

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    player()
    pygame.display.update()
下面是确切的错误:

Traceback (most recent call last):
  File "SpaceInvaders/main.py", line 20, in <module>
    playerImg = pygame.image.load('space-invaders.png')
pygame.error: Couldn't open space-invaders.png
回溯(最近一次呼叫最后一次):
文件“SpaceInvaders/main.py”,第20行,在
playerImg=pygame.image.load('space-invaders.png')
pygame.error:无法打开space-investors.png

请帮助我让空间入侵者使用前斜杠使用完整的文件路径这可能不是很有效,但总是有效的