上面是实现的截图,废话不说,直接开始说一下代码 pos = { 'UP': (-1,0), 'DOWN':(+1,0), 'LEFT':(0,-1), 'RIGHT':(0,+1), } current = 'RIGHT' snake = [[1,1],[1,2],[1,3],[1,4],[1,5]] #ex: [[1,1],[1,2],[1,3]] [y,x] head = snake[-1] snake_speed = 0.1 rany, ranx = -1, -1 来一些数据的初始化,蛇用…