Python密码生成原理

在string模块中定义了多个字符串常量,包括数字字符,标点符号,英文字母,大写字母,小写字母等,用户可直接使用这些常量

生成8个8位长度的密码

import string
import random
x=string.digits+string.ascii_letters+string.punctuation
passward=[''.join(random.sample(x,8)) for i in range(8)]
print(passward)

其中:string.digits为数字,包括0123456789

string.ascii_letters为字母,包括大写字母和小写字母

string.punctuation 为标点符号

猜你喜欢

转载自blog.csdn.net/lxy20011125/article/details/125294299