正则判断字符串必须包含大小写字母数字


def judge_password(password):
    if len(password) >= 8:
        pattern = re.compile('[A-Z]+')
        match = pattern.findall(password)
        if match:
            pattern = re.compile('[a-z]+')
            match = pattern.findall(password)
            if match:
                pattern = re.compile('[0-9]+')
                match = pattern.findall(password)
                if match:
                    return 'True'
                else:
                    return '必须包含数字'
            else:
                return '必须包含小写字母'
        else:
            return '必须包含大写字母'
    else:
        return '长度必须大于8位'

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM