letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ["0","1","2","3","4","5","6","7","8","9"]
combination = []
x = 0
for a in letters:
for b in letters:
for c in numbers:
for d in letters:
for e in letters:
for f in numbers:
for g in letters:
combination.append(a+b+c+d+e+f+g)
from string import ascii_uppercase, digits
from itertools import product
def all_combinations():
' pattern AA0AA0A '
A, O = ascii_uppercase, digits
# Use itertools product to generate all combinations of of
# lists of letters and digits
combs = product(A, A, O, A, A, O, A)
return map(''.join, combs)
# Test
seq = all_combinations() # create generation for combinations
# Show first 20
for i in range(20):
print(next(seq))
这是可能的,有976562500种可能性
小心!这个计算可能需要一段时间。如果RAM不超过16BG,也不要尝试运行此脚本
如果您使用的是JavaScript,则会有Randexp生成与给定正则表达式匹配的随机字符串
Releases for browser
使用生成器
注意:更新答案,并提供@ShadowRange、@Kelly Bundy、@supery rain)的建议
输出
相关问题 更多 >
编程相关推荐