python 全排列
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 全排列相关的知识,希望对你有一定的参考价值。
itertools模块现成的全排列:
for i in itertools.permutations(‘abcd‘,4): print ‘‘.join(i)
相关全排列算法:
def perm(l): if(len(l)<=1): return [l] r=[] for i in range(len(l)): s=l[:i]+l[i+1:] p=perm(s) for x in p: r.append(l[i:i+1]+x) return r
以上是关于python 全排列的主要内容,如果未能解决你的问题,请参考以下文章