1
bck = "C:\Python27\Lib\site-packages\back.jpg"
mse = "C:\Python27\Lib\site-packages\mouse.jpg"
import pygame, sys
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode((600,344),0,32)
background=pygame.image.load(bck).convert()
mouse_c=pygame.image.load(mse).convert_alpha()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.blit(background, (0,0))
x,y = pygame.mouse.get_pos()
x -= mouse_c.get_width()/2
y -= mouse_c.get_height()/2
screen.blit(mouse_c,(x,y))
pygame.display.update()
使用雙斜槓程序時,我得到這個錯誤,但圖像不顯示:pygame的不會加載圖像
File "C:\Python27\Lib\site-packages\game.py", line 12, in background=pygame.image.load(bck).convert() error: Couldn't open C:\Python27\Lib\site-packagesack.jpg
它似乎並沒有能夠找到圖像
當我使用雙斜線或轉發斜線它運行良好,但不顯示圖像。
我試過它在多個目錄中,它仍然無法正常工作。