最近在網上看到一些作品,然后對其進行了一些完善。只是用於學習,不要去干壞事哦。程序來源於網絡,我只是做了一些優化。
#!/usr/bin/python
# -*- coding:utf-8 -*-
# @Time :2019/10/7 10:55
# @Author :maple
# @Emall :1075495040@qq.com
# @File :密碼字典4.py
import itertools as its
words = input("請輸入想要生成的數字、字母、特殊符號:").strip()
word1 = input("請輸入前面的固定字符,若沒有直接enter:").strip()
word2 = input("請輸入后面的固定字符,若沒有直接enter:").strip()
len = int(input("請輸入密碼的長度,不包含前面和后面的固定字符:"))
words = set(words) #去重
words = ''.join(words) #拼接
#print(words)
r = its.product(words,repeat=len)
dic = open("dictionary.txt",'a')
for i in r:
dic.write(word1+''.join(i)+word2+"\n")
dic.close()