strD="您的密码安全评定为:低"
strM="您的密码安全评定为:中"
strG="您的密码安全评定为:高"
strB="请按以下方式提升您的密码安全级别:\
\n\t1.密码必须由数字、字母及特殊字符组合。\
\n\t2.密码只能由字母开头。\n\t3.密码长度不能低于16位。"
strnum='1234567890'
strletter='abcdefghigklmnopqrstuvwxyz'
strLetter='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
specialchars=r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''
mstr=""
while True:
pw=input("请输入需要检查的密码组合:").strip()
print(pw)
if pw[0].isalpha():#字母开头
for i in pw:
## print("我是密码中的一个:",i)
if (i in strnum) :mstr+='a'
elif(i in strletter):mstr+='b'
elif(i in strLetter):mstr+='b'
elif(i in specialchars):mstr+='c'
## print(mstr)
#定义:a=数字量,b=字母量,c=特殊字符量
lenstr=len(mstr)
num=mstr.count('a')
letter=mstr.count('b')
spchar=mstr.count('c')
## print("长度:",lenstr," 数字:",num," 字母:",letter," 特殊字符:",spchar)
if (num==lenstr or letter==lenstr or(num + letter==lenstr)) or lenstr<8:#低
print(strD+'\n'+strB)
elif ((num>0 and letter>0 and spchar==0)\
or (num>0 and spchar>0 and letter==0)\
or (letter>0 and spchar>0 and num==0)\
or (num>0 and letter>0 and spchar>0)) and 16>lenstr>=8 :#中
print(strM+'\n'+strB)
elif num>0 and letter>0 and spchar>0 and lenstr>=16:
print(strG+'\n'+strB)
else:
print(strB)
mstr=""