jos*_*eph 8 python string algorithm
我正在尝试创建一个循环来生成和打印字符串,如下所示:
所以,它会打印:
然后停止
agf*_*agf 23
from string import digits, ascii_uppercase, ascii_lowercase
from itertools import product
chars = digits + ascii_uppercase + ascii_lowercase
for n in range(1, 4 + 1):
for comb in product(chars, repeat=n):
print ''.join(comb)
Run Code Online (Sandbox Code Playgroud)
这首先是一个包含所有数字,大写字母和小写字母的字符串.
然后,对于1-4的每个长度,它打印这些数字和字母的每个可能组合.
请记住,这是很多组合 - 62 ^ 4 + 62 ^ 3 + 62 ^ 2 + 62.