(password)
return False
判断密码复杂度是否安全

    非弱口令标准：长度大于等于7，分别包含数字、小写、大写、特殊字符。
    @password: 密码文本
    @return: True/False
判断密码复杂度是否安全
判断密码复杂度是否安全
def is_strong_password(password):
    """判断密码复杂度是否安全

    非弱口令标准：长度大于等于7，分别包含数字、小写、大写、特殊字符。
    @password: 密码文本
    @return: True/False
    """

    if len(password) < 7:
        return False

    import re
    digit_reg = "[0-9]"  # 匹配数字 +1
    lower_case_letters_reg = "[a-z]"  # 匹配小写字母 +1
    upper_case_letters_reg = "[A-Z]"  # 匹配大写字母 +1
    special_characters_reg = r"((?=[\x21-\x7e]+)[^A-Za-z0-9])"  # 匹配特殊字符 +1

    regs = [digit_reg,
            lower_case_letters_reg,
            upper_case_letters_reg,
            special_characters_reg]

    grade = 0
    for reg in regs:
        if re.search(reg, password):
            grade += 1

    if grade == 4 or (grade >= 2 and len(password) >= 9):
        return True
    return False
def is_strong_password ( password ) : if len ( password ) < 7 : return False import re digit_reg = "[0-9]" # 匹配数字 +1 lower_case_letters_reg = "[a-z]" # 匹配小写字母 +1 upper_case_letters_reg = "[A-Z]" # 匹配大写字母 +1 special_characters_reg = r"((?=[\x21-\x7e]+)[^A-Za-z0-9])" # 匹配特殊字符 +1 regs = [ digit_reg , lower_case_letters_reg , upper_case_letters_reg , special_characters_reg ] grade = 0 for reg in regs : if re . search ( reg , password ) : grade += 1 if grade == 4 or ( grade >= 2 and len ( password ) >= 9 ) : return True return False