|
发表于 2020-3-6 23:04:54
|
显示全部楼层
首先你这程序就不有问题,其中一个break只能跳出一个for循环,无法跳出外层循环。
程序修改如下:其中判断都是按照你的判断写的
- X=['~','!','@','#',','%','^','&','*','(',')','_','=','-','/',',','.','?','<','>',';',':','[',']','{','}','|','\\']
- Y=['1','2','3','4','5','6','7','8','9','0']
- Z=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','u','s','t','u','v','w','x','y','z']
- while True:
- passwords=input('请输入注册密码:')
- flagx = False
- flagy = False
- flagz = False
- print(flagx,flagy,flagz)
- for each in passwords:
- if each in X:
- flagx = True
- elif each in Y:
- flagy = True
- elif each in Z:
- flagz = True
- print(flagx,flagy,flagz)
- if len(passwords)>= 16 and flagx and flagy and flagz and passwords[0] in Z:
- print('密码安全等级:高')
-
- elif 8<=len(passwords)<= 16 and (flagx + flagy +flagz ==2) :#判断符合2种规则
- print('密码安全等级:中')
- elif len(passwords)<8 and passwords.isdigit()==True:
- print('密码安全等级:低')
- else:
- print('其他类型的密码')
复制代码 |
|