本帖最后由 临时号 于 2022-8-11 12:05 编辑 passwd = input('请输入需要检查的密码组合:')
symbols = '~!@#$%^&*()_=-/,.?<>;:[]{}|\\'
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
nums = '0123456789'
#判断长度
length = len(passwd)
while (length == 0 or passwd.isspace()):
passwd = input('输入为空格或格式不正确,请重新输入:')
length = len(passwd)
if length < 8:
dengji_len = 1
elif 8 < length < 16:
dengji_len = 2
else:
dengji_len = 3
dengji_zuhe = 0
#判断字母
for each in passwd:
if each in chars:
dengji_zuhe += 1
break
#判断数字
for each in passwd:
if each in nums:
dengji_zuhe += 1
break
#判断特殊字符
for each in passwd:
if each in symbols:
dengji_zuhe += 1
break
while True:
print('您的密码安全级别评定为:',end='')
if dengji_len == 1 or dengji_zuhe == 1:
print('低')
elif dengji_len == 3 and dengji_zuhe == 3 and (passwd[0] in chars):
print('高')
break
else:
print('中')
print('haha')
|