[Python]順列と組み合わせを実現

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

参照:Pythonは順列と組み合わせを解決します

おすすめ

転載: blog.csdn.net/weixin_38705903/article/details/108315776