题解 | #密码强度等级#很笨的方法
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
def changdu(n):
lenscroll = 0
if len(n) <= 4:
lenscroll = 5
elif 5 <= len(n) <= 7:
lenscroll = 10
else:
lenscroll = 25
return lenscroll
def zimu(n):
phascroll = 0
list1 = [i for i in n if i.isalpha()]
if len(list1) == 0:
phascroll = 0
list2 = []#大写
list3 = []#小写
for k in list1:
if 'A' <= k <= 'Z':
list2.append(k)
elif 'a' <= k <= 'z':
list3.append(k)
if len(list2) == 0 or len(list3) == 0:
phascroll = 10
else :
phascroll = 20
return phascroll
def shuzi(n):
digscroll = 0
list4 = [i for i in n if i.isdigit()]
if len(list4) == 0:
digscroll = 0
elif len(list4) == 1:
digscroll = 10
else:
digscroll = 20
return digscroll
def fuhao(n):
fuscrool = 0
list5 = [i for i in n if ((32<= ord(i) <= 47) or (0x3A <= ord(i) <= 0x40) or (58 <= ord(i) <= 64) or (91 <= ord(i) <= 96))]
if len(list5) == 0:
fuscrool = 0
elif len(list5) == 1:
fuscrool = 10
else:
fuscrool = 25
return fuscrool
def jiangli(n):
jiangscroll = []
if zimu(n) != 0 and shuzi(n) != 0:
jiangscroll.append(2)
if fuhao(n) != 0:
jiangscroll.append(3)
if zimu(n) == 20 :
jiangscroll.append(5)
if len(jiangscroll) != 0:
return max(jiangscroll)
else:
return 0
def zongfen(n):
return changdu(n)+zimu(n)+shuzi(n)+fuhao(n)+jiangli(n)
s = input()
x = zongfen(s)
if zongfen(s) >= 90:
print('VERY_SECURE')
elif zongfen(s) >= 80:
print('SECURE')
elif zongfen(s) >= 70:
print('VERY_STRONG')
elif zongfen(s) >= 60:
print('STRONG')
elif zongfen(s) >= 50:
print('AVERAGE')
elif zongfen(s) >= 25:
print('WEAK')
else:
print('VERY_WEAK')


美的集团公司福利 713人发布