我在发布之前已经仔细搜索过了。我似乎有一个'模块'对象不可调用错误。这是我的代码:
""" Create Snake """
def createSnake():
x = randrange(0, 720, 20)
y = randrange(0, 480, 20)
size = 3
snakeBox = ""
snake = []
for i in range(size):
snakeBox = pygame.rect((x + 20*size, y + 20*size), (20, 20))
snake.append(snakeBox)
return snake
这是我在执行时收到的错误:
root@raspberrypi:/home/pi/Codes/Snake# python Snake.py
Traceback (most recent call last):
File "Snake.py", line 108, in <module>
if __name__ == '__main__': main()
File "Snake.py", line 106, in main
gameScreen()
File "Snake.py", line 95, in gameScreen
game()
File "Snake.py", line 57, in game
snake = createSnake()
File "Snake.py", line 49, in createSnake
snakeBox = pygame.rect((x + 20*size, y + 20*size), (20, 20))
TypeError: 'module' object is not callable
我似乎无法弄清楚错误是什么,因为我认为我已经正确导入了模块
from pygame.locals import *
感谢您的帮助:')