递归 def func(map_, n, m, x, y, x1, y1): """ n, x, x1: 行 m, y, y1: 列 """ if x > n-1 or y > m-1 or x < 0 or y < 0 or map_[x][y] == 1: return False if x == n-1 and y == m-1: return [(x, y)] new_steps = [(x+1, y), (x-1, y), (x, y+1), (x, y-1)] ...