python不带重复的全排列代码

代码如下:

from sys import argvscript, start, end = argvvis = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]def dfs(cur, m): ans[cur] = m if cur == int(end) – int(start) + 1: for i in xrange(int(start), int(end) + 1): print ans[i], print return cur = cur + 1 for i in xrange(int(start), int(end) + 1): if vis[i] == false: vis[i] = true dfs(cur, i) vis[i] = falsefor i in xrange(1, len(vis)): vis[i] = falsedfs(0, start)