Python自带的itertools模块就能实现
import itertools
nums = itertools.permutations([1,2,3])
for x in nums:
print(x)
>>>
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)
Python自带的itertools模块就能实现
import itertools
nums = itertools.permutations([1,2,3])
for x in nums:
print(x)
>>>
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)