2021年冬至是哪一天Python⽣成随机密码import random
import string
# ⽣成纯数字密码
def digits(length):
password = ''.join([random.choice(string.digits) for i in range(length)])
return password
# ⽣成纯⼩写密码
def lowercase(length):
password = ''.join([random.choice(string.ascii_lowercase) for i in range(length)])
return password
# ⽣成纯⼤写密码despacito歌词翻译中文
def uppercase(length):
password = ''.join([random.choice(string.ascii_uppercase) for i in range(length)])
return password
# ⽣成纯字符密码
def punctuation(length):
password = ''.join([random.choice(string.punctuation) for i in range(length)])
return password
# ⽣成纯随机字符密码
def password_random(length):
study的过去式和过去分词password = ''.join(
天枰座的男人[random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits + string.punctuation) for i in range(length)])
return password
# 输⼊密码长度
def password_length():
try:
pwd_length = int(input("请输⼊随机密码长度:"))
return pwd_length
except:
print("长度输⼊有误")
# ⽣成密码
def password_type():
print("-----⽣成随机密码,选择以下类型、⼤写、⼩写、数字、字符、随机-----")
pwd_tp = str(input("请输⼊随机密码类型:"))
try:
pwd_length = password_length()
if pwd_tp == "⼤写":
print(uppercase(pwd_length))
elif pwd_tp == "⼩写":
print(lowercase(pwd_length))
elif pwd_tp == "数字":
print(digits(pwd_length))
elif pwd_tp == "字符":
print(punctuation(pwd_length))
else:孙悟空的性格特点
print(password_random(pwd_length))教师节礼物送什么
except:
print("不能⽣成密码")
password_type()
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论