<p>似乎您希望获得递增的置换量,您可以使用<a href="https://docs.python.org/3/library/itertools.html" rel="nofollow noreferrer">^{<cd1>}</a>来实现此目的:</p>
<pre><code>from itertools import permutations
from pprint import pprint
data = range(6)
def inc_perms(it):
for i, _ in enumerate(data):
yield from permutations(data, i)
pprint(list(inc_perms(data)))
</code></pre>
<hr/>
<pre><code>[(0,),
(0, 1),
(1, 0),
(0, 1, 2),
(0, 2, 1),
(1, 0, 2),
(1, 2, 0),
(2, 0, 1),
(2, 1, 0),
(0, 1, 2, 3),
(0, 1, 3, 2),
(0, 2, 1, 3),
(0, 2, 3, 1),
(0, 3, 1, 2),
(0, 3, 2, 1),
(1, 0, 2, 3),
(1, 0, 3, 2),
(1, 2, 0, 3),
(1, 2, 3, 0),
(1, 3, 0, 2),
(1, 3, 2, 0),
(2, 0, 1, 3),
(2, 0, 3, 1),
(2, 1, 0, 3),
(2, 1, 3, 0),
(2, 3, 0, 1),
(2, 3, 1, 0),
(3, 0, 1, 2),
(3, 0, 2, 1),
(3, 1, 0, 2),
(3, 1, 2, 0),
(3, 2, 0, 1),
(3, 2, 1, 0),
(0, 1, 2, 3, 4),
(0, 1, 2, 4, 3),
(0, 1, 3, 2, 4),
(0, 1, 3, 4, 2),
(0, 1, 4, 2, 3),
(0, 1, 4, 3, 2),
(0, 2, 1, 3, 4),
(0, 2, 1, 4, 3),
(0, 2, 3, 1, 4),
(0, 2, 3, 4, 1),
(0, 2, 4, 1, 3),
(0, 2, 4, 3, 1),
(0, 3, 1, 2, 4),
(0, 3, 1, 4, 2),
(0, 3, 2, 1, 4),
(0, 3, 2, 4, 1),
(0, 3, 4, 1, 2),
(0, 3, 4, 2, 1),
(0, 4, 1, 2, 3),
(0, 4, 1, 3, 2),
(0, 4, 2, 1, 3),
(0, 4, 2, 3, 1),
(0, 4, 3, 1, 2),
(0, 4, 3, 2, 1),
(1, 0, 2, 3, 4),
(1, 0, 2, 4, 3),
(1, 0, 3, 2, 4),
(1, 0, 3, 4, 2),
(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