题解 | #密码强度等级#
密码强度等级
http://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
# -*-coding:utf-8-*-
import re
while True:
try:
input_s = input()
score = 0
if len(input_s) <= 4:
score += 5
elif len(input_s) in (5 , 6 , 7):
score += 10
elif len(input_s) >= 8:
score += 25
fs = str(re.findall(r'[a-zA-Z]+' , input_s))
if not fs:
score += 0
elif fs.isupper() or fs.islower():
score += 10
elif re.findall(r'[a-z]+' , input_s) and re.findall(r'[A-Z]+' , input_s):
score += 20
if not re.findall(r'[0-9]+' , input_s):
score += 0
elif len(re.findall(r'[0-9]{1}' , input_s)) >1:
score += 20
elif re.findall(r'[0-9]' , input_s):
score += 10
if not re.findall(r'[\W]+' , input_s):
score += 0
elif len(re.findall(r'[\W]{1}' , input_s))>1:
score += 25
elif re.findall(r'[\W]' , input_s):
score += 10
if re.findall(r'[a-z]' , input_s) and re.findall(r'[A-Z]' , input_s) and re.findall(r'[0-9]' ,input_s) and re.findall(r'[\W]' ,input_s):
score += 5
elif re.findall(r'[a-zA-Z]' , input_s) and re.findall(r'[0-9]' , input_s) and re.findall(r'[\W]' , input_s):
score += 3
elif re.findall(r'[a-zA-Z]' , input_s) and re.findall(r'[0-9]' , input_s) :
score += 2
if score >= 90:
print('VERY_SECURE')
elif score >= 80:
print('SECURE')
elif score >= 70:
print('VERY_STRONG')
elif score >= 60:
print('STRONG')
elif score >= 50:
print('AVERAGE')
elif score >= 25:
print('WEAK')
elif score >= 0:
print('VERY_WEAK')
except:
break