[Python] realize permutation and combination

import itertools
res = []
for i in itertools.permutations('123', 3):
    res.append(''.join(i))
# 输出 ['123', '132', '213', '231', '312', '321']
print(res)

Reference: python solves permutation and combination

Guess you like

Origin blog.csdn.net/weixin_38705903/article/details/108315776