题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
''' 耗了我一天多才通过🤨,必须贴出来记录一下! ''' a = input() jc = 0 dx,xx = 0,0 sz = 0 fhj = "!\"#$%&'()*+,-./:;<=>?@ [\]^_`{|}~" fh =0 for i in a: if i.isalpha(): if i.isupper(): dx +=1 else: xx +=1 elif i.isdigit(): sz +=1 elif i in fhj: fh +=1 if len(a)<= 4: # 长度判断 jc +=5 elif 5 <=len(a) <=7: jc += 10 elif len(a)>7: jc += 25 while 1: # 大小写个数判断 zm = dx + xx if (dx >0) and (xx >0) and (zm >1): jc +=20 break elif (zm == dx) or (xx == dx+xx): jc +=10 break elif (dx == 0) or (xx == 0): break while 1: # 数字个数判断 if sz ==0: break elif sz ==1: jc +=10 break elif sz >1: jc +=20 break while 1: # 符号个数判断 if fh ==0: break elif fh ==1: jc +=10 break elif fh >1: jc +=25 break zf =0 while 1: # 奖励判断 if (dx >0) and (xx >0) and (sz >0) and (fh >0): zf = jc +5 break elif (dx+xx >0) and (sz >0) and (fh >0): zf = jc +3 break elif (dx+xx >0) and (sz >0) and (fh ==0): zf = jc +2 break else: zf = jc break if zf >=90: print("VERY_SECURE") elif 80<=zf<=89: print("SECURE") elif 70<=zf<=79: print("VERY_STRONG") elif 60<=zf<=69: print("STRONG") elif 50<=zf<=59: print("AVERAGE") elif 25<=zf<=49: print("WEAK") elif 0<=zf<=24: print("VERY_WEAK")