import itertools variations = itertools.product('abc',repeat=3) for variations in variations: variation_string = "" for letter in variations: variation_string += letter print (variation_string)@H_301_2@
如果是我,我会使用David Heffernan的方法将您的变量写入文本文件(因为其他方法要求用户使用命令提示符).
import itertools file = open('out.txt','w') variations = itertools.product('abc',repeat=3) for variations in variations: variation_string = "" for letter in variations: variation_string += letter file.write(variation_string) file.close()@H_301_2@