我是 Python 的新手。我正在尝试制作一个简单的蛇游戏,但它一直给我这些错误。(我正在使用 python 3.7.1 和 pygame 1.9.6)

I'm new to Python. I'm trying to make a simple snake game,but it keeps giving me these errors.(I am using python 3.7.1 and pygame 1.9.6)

class Snake(pygame.sprite.Sprite):
    image: Union[SurfaceType, Any]

    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image=pygame.Surface((12,12))
        self.image.dill(WHITE)
        self.rect=self.image.get_rect()
        self.rect.center=(100,100)
        self.speedx=0
        self.speedy=0
        self.score=0
        self.tail=[]

class Food(pygame.sprite.Sprite):
    def __init__(self,x,y):
        pygame.sprite.Sprite.__init__(self)
        self.image=pygame.Surface((12,12))
        self.image.fill(RED)
        self.rect=self.image.get_rect()
        self.rect.center=(x,y)

all_sprites=pygame.sprite.Group()
player=Snake()
food=Food(random.randrange(20,width-20),random.randrange(20,height-20))
all_sprites.add(player)
all_sprites.add(food)

错误:

Traceback (most recent call last):  
  File "C:/Users/Asus/Documents/snake.py", line 100, in <module>  
    player=Snake()  
  File "C:/Users/Asus/Documents/snake.py", line 48, in __init__  
    self.image.dill(WHITE)  
AttributeError: 'pygame.Surface' object has no attribute 'dill'  

我想你的意思是 'fill' 而不是第 7 行的 dill。