发布时间:2019-09-25 08:22:44编辑:auto阅读(3143)
最近1年自学了python,发现python的应用场景挺多,自己百度了加自己稍微修改,写了段可以随时生成指定长度的安全随机密码
#C:\Python36
#coding=utf-8
import string
from random import choice
passwd_length = int(input('The length of password: ')) #密码的长度
passwd_count = int(input('The number of password lists: ')) #生成几组密码
symbols = '!@#$%&*+=' #定义使用哪些特殊字符,可以自己定义修改
passwd_seed = string.digits + string.ascii_letters + symbols #密码的类型定义,数字+字母+特殊字符,(如果使用string.punctuation是使用所有的特殊字符,包括'.',不好识别)
def generate_passwd():
passwd = []
while (len(passwd) < passwd_length):
passwd.append(choice(passwd_seed))
return ''.join(passwd)
if __name__ == '__main__':
for i in range(0, passwd_count):
print(generate_passwd())
上一篇: python3 列表 元组 字典 文件
下一篇: python3不再支持mysqldb 请
54412
41173
35697
31263
26168
25885
24371
19915
15957
15405
2266°
2076°
2169°
2286°
2254°
2463°
2402°
2216°
2294°
2269°