发布时间:2019-09-25 08:22:44编辑:auto阅读(3238)
最近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 请
54949
41742
36327
31766
26664
26353
24880
20487
16424
15841
2971°
2702°
2802°
2946°
2879°
3143°
3036°
2880°
2871°
2848°