num = '1,2,3,4,5,6,7,8,9,0'
letter = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'
str1 = r'''~`!@#$%^&*()_+=-\|]}[{"':;?/>.<,'''
def check(password):
global level
level = 0
for each in password:
if each in num:
level += 1
break
for each in password:
if each in letter:
level += 1
break
for each in password:
if each in str1:
level += 1
break
return level
tip = (
"请按以下方式提升您的密码安全级别:\n"
"\t1.密码必须由数字、字母及特殊字符三种组合\n"
"\t2.密码只能由字母开头\n"
"\t3.密码长度不能低于16位\n")
while 1:
global level
password = input('请输入密码:')
long = len(password)
check(password)
if password[0] not in letter or long <= 8 or level == 1:
print('您的密码安全级别评定为:低')
print(tip)
continue
elif password[0] in letter and long > 8 and level == 2:
print('您的密码安全级别评定为:中')
print(tip)
continue
elif password[0] in letter and long > 16 and level == 3:
print('您的密码安全级别评定为:高')
print('请继续保持')
break