用于解密时生成字典,也可以内置调用,减少IO消耗。
直接根据长度返回字典
def create_dictionary(lenth:int):
words = ''
# 生成字根(大小写+数字)
for i in range(48, 123):
if 57 < i < 65 or 90 < i < 97:
continue
words += chr(i)
# 生成字典
index = 0
dictionary = []
for i in range(1, lenth + 1):
r = its.product(words, repeat=i)
for j in r:
index += 1
print("".join(j))
dictionary.append("".join(j))
print(index)
return dictionary
目前存在的问题:如果长度稍大,返回list长度的就有指数级增加。后期优化方向为每调用一次只返回字典中的一个,再次调用返回下一个。有思路的同学可以指导下。



