#dfs 迷宫问题 dirs = [(0,1),(1,0),(0,-1),(-1,0)] queue = [] #四个方向 def mark(maze,pos): maze[pos[0]][pos[1]] = 2 def dfs(maze,start,end): stack = [] mark(maze,start) stack.append((start,0)) while len(stack) > 0: pos,nxt = stack.pop(0) for i in range(nxt,4): ...