题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
#那些直接用isdig isupper islower判断的更推荐
import re
a=input()
s=0
dig=False
ab=False
AB=False
fuhao=False
#判断长度
if len(a)<=4:
s+=5
elif len(a)>=5 and len(a)<=7:
s+=10
elif len(a)>=8:
s+=25
# print(s)
#判断是否有字母
if re.search('[a-z]',a):
ab=True
s+=10
if re.search('[A-Z]',a):
AB=True
s+=10
# print(s)
#判断数字
if re.search('[0-9]',a):
dig=True
if len(re.findall('[0-9]',a))==1:
s+=10
else:
s+=20
# print(s)
#判断符号
if re.search('[^a-zA-Z0-9]',a):
fuhao=True
if len(re.findall('[^a-zA-Z0-9]',a))==1:
s+=10
elif len(re.findall('[^a-zA-Z0-9]',a))>1:
s+=25
if dig and ab and not fuhao and not AB:
s+=2
elif dig and AB and not fuhao and not ab:
s+=2
elif dig and ab and fuhao and not AB:
s+=3
elif dig and AB and fuhao and not ab:
s+=3
elif dig and ab and fuhao and AB:
s+=5
# print(s)
if s>=90:
print("VERY_SECURE")
if s>=80 and s<90:
print("SECURE")
if s>=70 and s<80:
print("VERY_STRONG")
if s>=60 and s<70:
print("STRONG")
if s>=50 and s<60:
print("AVERAGE")
if s>=25 and s<50:
print("WEAK")
if s>=0 and s<25:
print("VERY_WEAK")