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在理解代碼的內部運作方面存在更多問題。 –