我所要做的就是加载一张像是背景的图片,它会一直给出同样的错误。
这是我的代码:
import pygame, sys,os
from pygame.locals import *
pygame.init()
background = os.path.join("\\\A-FS-02\Home$\ytsmaj\My Documents\ICS 201\Stuff With Pygame\ISU\slotbackroundfit.png")
backround_surface = pygame.image.load(background)
backgroundRect = background.get_rect()
size = (width, height) = background.get_size(584, 648)
screen = pygame.display.set_mode(size)
这是我得到的错误:
Traceback (most recent call last):
File "\\A-FS-02\Home$\ytsmaj\My Documents\ICS 201\Stuff With Pygame\ISU\slotmachinetest.py", line 10, in <module>
backgroundRect = background.get_rect()
AttributeError: 'str' object has no attribute 'get_rect'
我真的不知道出了什么问题,因为我是pygame
的新人。