1
这种递归方法如何工作产生排列给定一个字符串?有人可以解释我吗?我不明白这种递归方法在Python中产生排列
def exchange(self, s):
if 0 == len(s):
yield s
else:
for i in range(len(s)):
for p in self.exchange(s[:i] + s[i + 1:]):
yield [s[i]] + p
它被称为[“生成器”](https://wiki.python.org/moin/Generators) – rickdenhaan
相关:https://stackoverflow.com/questions/231767/what-does-the-yield-keyword python – MLavrentyev
@rickdenhaan:我认为这很清楚。我认为OP在理解代码的内部运作方面存在更多问题。 –