Python第14讲动动手
symbols =r''' ~!@#$%^&*()_=-/,.?<>;:[]{}|\'''number ='0123456789'
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
passwd = input('请输入需要检查的密码组合:')
length = len(passwd)
while (passwd.isspace()) or (length ==0))
print('你的密码为空,请重新输入:'end = '')
continue
if length <= 8:
flag_len = 1
elif 8 < length <16:
flag_len = 2
else:
flag_len = 3
flag_con = 0
for each in passwd:
if each in symbols:
flag_con += 1
break
for each in passwd:
if each in chars:
flag_con += 1
break
for each in passwd:
if each in number:
flag_con += 1
break
while 1:
print''您的密码安全等级为:'',end = '')
if flag_len == 1 or flag_con == 1:
print('低')
elif flag_len ==3 and flag_con ==3 and (passwd in chars):
print('高')
print('请继续保持')
break
else:
print('中')
print('请按以下方式提升您的密码等级:\n
\t1.密码必须由数字、字母及特殊字符三种组合\n
\t2.,密码只能有字母开头\n
\t3.密码长度不能低于16位')
break
铁汁们,我运行的时候回返回EOF while scanning triple-quoted string literal,我实在是找不到哪里错了。。 1行,不要把\放在最后,放到前面就好了。 1.while语句没冒号,且少了左括号
2.print('你的密码为空,请重新输入:'end = '')错误,print('你的密码为空,请重新输入:',end = '')正确
symbols = r"""~!@#$%^&*()_=-/,.?<>;:[]{}|\""""
number = '0123456789'
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
passwd = input('请输入需要检查的密码组合:')
length = len(passwd)
while ((passwd.isspace()) or (length == 0)):
print('你的密码为空,请重新输入:', end='')
continue
if length <= 8:
flag_len = 1
elif 8 < length < 16:
flag_len = 2
else:
flag_len = 3
flag_con = 0
for each in passwd:
if each in symbols:
flag_con += 1
break
for each in passwd:
if each in chars:
flag_con += 1
break
for each in passwd:
if each in number:
flag_con += 1
break
while 1:
print('您的密码安全等级为: ', end='')
if flag_len == 1 or flag_con == 1:
print('低')
elif flag_len == 3 and flag_con == 3 and (passwd in chars):
print('高')
print('请继续保持')
break
else:
print('中')
print('请按以下方式提升您的密码等级:\n\t1.密码必须由数字、字母及特殊字符三种组合\n\t2.,密码只能有字母开头\n\t3.密码长度不能低于16位')
break symbols = r" ~!@#$%^&*()_=-/,.?<>;:[]{}|" "\\"# 不能以反斜杠结尾,将反斜杠换个位置或者像这样反斜杠单独重起一对引号
number = "0123456789"
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
passwd = input("请输入需要检查的密码组合:")
length = len(passwd)
while passwd.isspace() or (length == 0):# isspace()后面多了一个),本行末尾少了:号
print("你的密码为空,请重新输入:", end="")# end前面少了,号
continue
if length <= 8:
flag_len = 1
elif 8 < length < 16:
flag_len = 2
else:
flag_len = 3
flag_con = 0
for each in passwd:
if each in symbols:
flag_con += 1
break
for each in passwd:
if each in chars:
flag_con += 1
break
for each in passwd:
if each in number:
flag_con += 1
break
while 1:
print("您的密码安全等级为:", end="")# print后漏了(,而且字符串不能两个单引号开始两个单引号结束
if flag_len == 1 or flag_con == 1:
print("低")
elif flag_len == 3 and flag_con == 3 and (passwd in chars):
print("高")
print("请继续保持")
break
else:
print("中")
print(
"""请按以下方式提升您的密码等级:\n
\t1.密码必须由数字、字母及特殊字符三种组合\n
\t2.,密码只能有字母开头\n
\t3.密码长度不能低于16位"""
)# 多行字符串要用三引号括起来
break
页:
[1]