Python实现判断强密码

不使用正则表达式,判断一个字符串是否满足强密码要求。(长度 >= 10,至少出现以下情况中的三种:大写字母、小写字母、数字、符号集(_ ! @ #);且不包括其他字符)

import string
x = input("请输入一组密码:\n")
def demo(L):
    L = []
    k = len(L)
    if k >= 10:
        if L.isalnum() and not L.isdigit() and not L.isalpha()and not L.isspace():
            return print("是强密码\n")
        else:
            L = L.replace("!","")
            L = L.replace("_","")
            L = L.replace("#","")
            L = L.replace("@","")
            m = len(L)

            if k != m and L.isalnum()and not L.isdigit() and not L.isalpha():
                return print("是强密码\n")
            elif k != m and L.isalpha() and not L.lower() in L and not L.upper() in L:
                return print("是强密码\n")
            else:
                return print("不是强密码\n")
    else:
        return print("不是强密码\n")

你可能感兴趣的:(Python3学习)