题解 | #密码强度等级#

密码强度等级

http://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361

import re
while True:
    try:
        words= input()
    except:
        break
    else:
        num  = len(words)
        scores =0
        dic_c ={'low_alpha':0,'upper_alpha':0,'number':0,'ss':0}
        string = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
        ## 1. length
        if num <=4:
            scores+=5
        elif num>=5 and num <=7:
            scores+=10
        else:
            scores+=25
        ##2. alpha number
        for word in words:
            if word.isalpha():
                if word.islower():
                    dic_c['low_alpha']+=1
                if word.isupper():
                    dic_c['upper_alpha']+=1
            elif word.isdigit():
                dic_c['number']+=1
            elif word in string:
                dic_c['ss']+=1

        if dic_c['low_alpha']>0 and dic_c['upper_alpha']>0:
            scores+=20
        elif dic_c['low_alpha']>0 or dic_c['upper_alpha']>0:
            scores+=10
        else:
            scores+=0
            
        if dic_c['number']>1:
            scores+=20
        elif dic_c['number']==1:
            scores+=10
        else:
            scores+=0

        ## 3. 
        if dic_c['ss']==1:
            scores+=10
        elif dic_c['ss']>1:
            scores+=25
        
        # reward
        if dic_c['number']>0:
            if dic_c['low_alpha']>0 and dic_c['upper_alpha']>0:
                if dic_c['ss']>0:
                    scores+=5
            elif dic_c['low_alpha']>0 or dic_c['upper_alpha']>0:
                if dic_c['ss']>0:
                    scores+=3
                else:
                    scores+=2
        if scores >=90:
            print("VERY_SECURE")
        elif scores >=80:
            print("SECURE")
        elif scores >=70:
            print("VERY_STRONG")
        elif scores >=60:
            print("STRONG")
        elif scores >=50:
            print("AVERAGE")
        elif scores >= 25:
            print("WEAK")
        elif scores >= 0:
            print("VERY_WEAK")
         
全部评论

相关推荐

05-12 11:09
已编辑
门头沟学院 后端
已注销:没必要放这么多专业技能的描述。这些应该是默认已会的,写这么多行感觉在凑内容。项目这块感觉再包装包装吧,换个名字,虽然大家的项目基本都是网上套壳的,但是你这也太明显了。放一个业务项目,再放一个技术项目。技术项目,例如中间件的一些扩展和尝试。
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务