使用ASCII码来判断大小写字母以及数字非常好用,建议可以考虑使用,而不是使用islower()和isupper()之类的方法
a = input()
length = len(a)
lowerchactor = 0
higherchactor = 0
number = 0
other = set()
for i in a:
if ord("a")<=ord(i)<=ord("z"):#小写
lowerchactor += 1
elif ord("A")<=ord(i)<=ord("Z"):#大写
higherchactor += 1
elif ord("0")<=ord(i)<=ord("9"):#数字
number += 1
else:#其他字符
other.add(i)
result = 0
if length <=4:#密码长度
result += 5
elif 5<=length <=7:
result += 10
elif length >= 8:
result += 25
if lowerchactor == 0 and higherchactor == 0:#字母大小写混合
result += 0
elif lowerchactor > 0 and higherchactor >0:
result +=20
else:
result += 10
if number >1:
result += 20
elif number == 1:
result += 10
else:
result += 0
if len(other) == 0:
result += 0
elif len(other) == 1:
result += 10
else:
result += 25
if lowerchactor != 0 and higherchactor != 0:
if len(other) != 0 and number != 0:
result += 5
elif lowerchactor != 0 or higherchactor != 0 and len(other) != 0 and number != 0:
result += 3
elif lowerchactor != 0 or higherchactor != 0 and len(other) == 0 and number != 0:
result += 2
if result >= 90:
print("VERY_SECURE")
elif result >= 80:
print("SECURE")
elif result >= 70:
print("VERY_STRONG")
elif result >= 60:
print("STRONG")
elif result >= 50:
print("AVERAGE")
elif result >= 25:
print("WEAK")
elif result >= 0:
print("VERY_WEAK")



京公网安备 11010502036488号