|
发表于 2020-7-15 10:23:32
|
显示全部楼层
本楼为最佳答案
本帖最后由 qiuyouzhi 于 2020-7-15 10:56 编辑
地狱拖拉机 发表于 2020-7-15 10:19
symbols = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.'''
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO ...
正确代码:
- symbols = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''
- chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- nums = '0123456789'
- passwd = input('请输入需要检查的密码组合:')
- length = len(passwd)
- while (passwd.isspace() or length == 0):
- passwd = input("您输入的密码为0或者空格,请重新输入")
- length = len(passwd)
- lensecurity = 0
- if length <= 8:
- lensecurity = 1
- elif 8 < length < 16:
- lensecurity = 2
- else:
- lensecurity = 3
- complexsecurity = 0
- for each in passwd:
- if each in symbols:
- complexsecurity += 1
- break
- for each in passwd:
- if each in chars:
- complexsecurity += 1
- break
- for each in passwd:
- if each in nums:
- complexsecurity += 1
- break
- while 1:
- if lensecurity == 1 or complexsecurity ==1:
- print("您的密码安全级别评定为:低")
- elif lensecurity ==3 and complexsecurity ==3:
- print("您的密码安全级别评定为:高")
- break
- else:
- print("您的密码安全级别评定为:中")
- print("请按以下方式提升您的密码安全级别:\n\
- \t1. 密码必须由数字、字母及特殊字符三种组合\n\
- \t2. 密码只能由字母开头\n\
- \t3. 密码长度不能低于16位")
- break
复制代码
跟着视频敲代码要认真些 , 最前面漏了变量 length 、变量名输入错误、 字符串方法错误,是 isspace() 不是 isspave()。
|
|