用itertools生成7位数的所有排列组合

用itertools生成7位数的所有排列组合

"""生成7位数的所有排列组合

"""

import itertools as its
words = "1234567890"

all_comb = []

for n in range(7):
    r = its.product(words,repeat=n)
    for i in r:
        all_comb.append("".join(i))


f = open("dict.txt",'w')
for s in all_comb:
    f.write(s + "\n")
f.close()

 

李兴球

李兴球的博客是Python创意编程原创博客