我试图制作一个强力算法。 我会在00000000(8个数字)和999999999999(12个数字)之间打印所有可能的数字组合
我找到了这段代码:
for c in itertools.product(numbers, repeat=12):
pin = y+''.join(c)
print(pin)
但是使用这段代码我无法设置最小长度,所以它从000000000000(12个数字)开始
有什么想法吗?
答案 0 :(得分:2)
numbers = '01' # you could use '0123456789' but that would take very long
y = 'foo'
for length in range(8, 13):
for c in itertools.product(numbers, repeat=length):
pin = y+''.join(c)
print(pin)