Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在此消息中,作者写道
def neighbors((x, y)):
当我尝试使用 Python 3.3 运行它时,它告诉我这是无效的语法。我该如何解决这个问题?
解决办法是:
def neighbors(point): x, y = point
由于多种原因,此功能已从 3.x 中删除。
另一种选择是将其写为
def neighbors(x, y):
并替换:
for (nx, ny) in neighbors(path[-1]):
和
for (nx, ny) in neighbors(*path[-1]):