python代码,样例通过但是wa,求指导

B3843 [GESP202306 三级] 密码合规

PPAP91 @ 2024-11-28 17:32:39

a=str(input()) a= a.split(",", -1)#分段 for i in a: b=0 e = n = t = a =0 if len(i)>12 or len(i)<6:#判断长度 continue else: for j in i: #截取字符串判断是否合法 if 97<=ord(j)<=122 or 65<=ord(j)<=90 or ord(j)==33 or ord(j)==64 or ord(j)==35 or ord(j)==36 or 48<=ord(j)<=57: if 97<=ord(j)<=122 :#统计整数大小写字母和特殊字符个数 e += 1 elif 65<=ord(j)<=90: a += 1 elif 48<=ord(j)<=57: n += 1 elif ord(j)==33 or ord(j)==64 or ord(j)==35 or ord(j)==36: t += 1 else: b=b+1 break if b==1 or t==0 :#字符不合法以及特殊字符小于一个,跳过 continue elif ea==0 or en==0 or a*n==0:#大小写字母和数字种类小于两个,跳过 continue print(i)

a=str(input())
a= a.split(",", -1)#分段
for i in a:
    b=0
    e = n = t = a =0
    if len(i)>12 or len(i)<6:#判断长度
        continue
    else:
        for j in i: #截取字符串判断是否合法
            if 97<=ord(j)<=122 or 65<=ord(j)<=90 or ord(j)==33 or ord(j)==64 or ord(j)==35 or ord(j)==36 or 48<=ord(j)<=57:
                if 97<=ord(j)<=122 :#统计整数大小写字母和特殊字符个数
                    e += 1
                elif 65<=ord(j)<=90:
                    a += 1
                elif 48<=ord(j)<=57:
                    n += 1
                elif  ord(j)==33 or ord(j)==64 or ord(j)==35 or ord(j)==36:
                    t += 1
            else:
                    b=b+1
                    break 
    if  b==1 or t==0  :#字符不合法以及特殊字符小于一个,跳过
        continue
    elif e*a==0 or e*n==0 or a*n==0:#大小写字母和数字种类小于两个,跳过
        continue
    print(i)

by Estelle_N @ 2024-11-28 17:45:46

@PPAP91

elif (e == 0 and a == 0) or (e == 0 and n == 0) or (a == 0 and n == 0):#大小写字母和数字种类小于两个,跳过


by laijinqi1006 @ 2024-11-28 18:01:43

@PPAP91 举个例子,e=0,a=2,n=10

e*a==0满足了,但它是合法的


by PPAP91 @ 2024-11-29 09:54:04

@Estelle_N谢谢谢谢


by PPAP91 @ 2024-11-29 09:54:27

@laijinqi1006明白了,感谢


|