求修改
GatherNum = '0123456789'GatherLetter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
GatherSymbol = r'~!@#$%^&*()_=-,./?<>;:[]{}\|'
while True:
psw = input('请输入需要检查的密码组合(Ctrl+C to Cancel):')
length = len(psw)
#空白或空格判断
while (psw.isspace() or length == 0):
psw = input('密码为空或空格,请重新输入:')
length = len(psw)
#长度判断
print(length)
if length < 8:
length_l = 1
elif length >= 8 and length < 16:
length_l = 2
else:
length_l = 3
charkind = 0
#数字判断
for i in psw:
if i in GatherNum:
charkind = 1
break
#字母判断
for i in psw:
if i in GatherLetter:
charkind += 1
break
#特殊字符判断
for i in psw:
if i in GatherSymbol:
charkind += 1
break
print(length_l,charkind)
print('你的密码安全级别为:',end='')
if length_l == 1 or charkind == 1:
print('低\n\
@长度太短,或者仅有数字、或者仅有字母')
elif length_l == 3 and charkind == 3 and (psw in GatherLetter):
print('高\n继续保持您的优秀!!!')
break
else:
print('中')
print('\t请按以下策略提升密码安全级别:\n\
\t1. 密码必须由数字、字母及特殊字符中的3种\n\
\t2. 密码只能由字母开头\n\
\t3. 密码长度不能低于16位\n') GatherNum = '0123456789'
GatherLetter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
GatherSymbol = r'~!@#$%^&*()_=-,./?<>;:[]{}\|'
psw = input('请输入需要检查的密码组合(Ctrl+C to Cancel):')
length = len(psw)
#空白或空格判断
while (psw.isspace() or length == 0):
psw = input('密码为空或空格,请重新输入:')
length = len(psw)
#长度判断
print(length)
if length < 8:
length_l = 1
elif length >= 8 and length < 16:
length_l = 2
else:
length_l = 3
charkind = 0
#数字判断
for i in psw:
if i in GatherNum:
charkind = 1
#字母判断
for i in psw:
if i in GatherLetter:
charkind += 1
#特殊字符判断
for i in psw:
if i in GatherSymbol:
charkind += 1
print(length_l,charkind)
print('你的密码安全级别为:',end='')
if length_l == 1 or charkind == 1:
print('低\n\
@长度太短,或者仅有数字、或者仅有字母')
elif length_l == 3 and charkind == 3 and (psw in GatherLetter):
print('高\n继续保持您的优秀!!!')
else:
print('中')
print('\t请按以下策略提升密码安全级别:\n\
\t1. 密码必须由数字、字母及特殊字符中的3种\n\
\t2. 密码只能由字母开头\n\
\t3. 密码长度不能低于16位\n')
页:
[1]