|
7鱼币
- print ('请输入需要检查的密码组合:',end='')
- password = input()
- symbol1 = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'
- symbol2 = '0123456789'
- symbol3 = r'''~!@#$%^&*()_=-/,.?<>;:[]{}|\'''#这一行自己写的,选择这一行就报错
- #symbol3 = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''#选择这一行不会报错
- time1 = 0#这里报错,syntaxerror invaild syntax
- time2 = 0
- time3 = 0
- number = 0
- if len(password) ==0 or password.isspace():
- print ('您未输入密码或者全是空格,请重新输入:',end='')
- password = input()
- while 1:
- for each in password:
- number +=1
- if time1 == 0:
- if each in symbol1:
- time1 +=1
- if time2 == 0:
- if each in symbol2:
- time2 +=1
- if time3 == 0:
- if each in symbol3:
- time3 +=1
- if each not in symbol1 and each not in symbol2 and each not in symbol3:
- print ('密码中还有偏僻字符,请重新输入:',end='')
- password =input()
- break
- if number == len(password):
- break
- length = len(password)
- piece = password[:1]
- if length <= 8:
- temp = 1
- elif length >= 16:
- temp = 3
- else :
- temp = 2
- print('您输入的密码等级:',end='')
- if temp ==3 and piece.isalpha() and time1 ==1 and time2 ==1 and time3 ==1:
- print('高')
- elif time1 ==1 and time2 ==1 and time3 ==1:
- print('中')
- elif temp ==2 and (time1+time2+time3 ==2):
- print('中')
- elif (time1+time2+time3 ==2):
- print('低')
- else:
- print('低')
- print ('请按以下方式提升您的密码安全等级:')
- print ('\t1.密码必须有数字、字母及特殊字符组成\n\t2.密码只能由字母开头\n\t3.密码长度不能低于16位')
复制代码
因为你自己些的将 \ 转义符放在了最后一个字符中,导致字符串的 ' 一个单引号被转义,导致右引号少了一个而报错
你的代码最后多加个 \ 即可,参考代码:
- symbol3 = r'''~!@#$%^&*()_=-/,.?<>;:[]{}|\\'''
复制代码
使用三引号是因为字符串中需要有 单引号或者 双引号,否则 Python 会将字符串字符中的引号当成结束的右引号
|
最佳答案
查看完整内容
因为你自己些的将 \ 转义符放在了最后一个字符中,导致字符串的 ' 一个单引号被转义,导致右引号少了一个而报错
你的代码最后多加个 \ 即可,参考代码:
使用三引号是因为字符串中需要有 单引号或者 双引号,否则 Python 会将字符串字符中的引号当成结束的右引号
|