关于Python第14讲课后题动手题
按照参考代码敲的,却报错语法错误,求大佬指点,使用的是python3,圈红部分是报错提示的地方print('==============================RESTART==============================\n')
symbols = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''
alphas = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
nums = '0123456789'
password = input('请输入需要检查的密码组合:')
length = len(password)
while (password.isspace()) or (length == 0):
password = input('您输入的密码为空(或空格),请重新输入:')
length = len(password)
if length <= 8:
flaglen = 1
if 8 < length <= 16:
flaglen = 2
if length >= 16:
flaglen = 3
flagcon = 0
for i in password:
if i in symbols:
flagcon += 1
break
for i in password:
if i in nums:
flagcon += 1
break
for i in password:
if i in alphas:
flagcon += 1
break
while 1:
print('您的密码安全级别评定为:',end'')
if flaglen == 1 or flagcon == 1:
print('低')
elif flaglen == 3 and flagcon == 3 and (password in alphas):
print('高')
print('请继续保持')
break
else:
print('中')
print('''请按以下方式提升您的安全级别:
1.密码必须由数字、字母及特殊字符三种组合
2.密码只能由字母开头
3.密码长度不能低于16位''')
break
第32行,end后面少了个等号
print('==============================RESTART==============================\n')
symbols = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''
alphas = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
nums = '0123456789'
password = input('请输入需要检查的密码组合:')
length = len(password)
while (password.isspace()) or (length == 0):
password = input('您输入的密码为空(或空格),请重新输入:')
length = len(password)
if length <= 8:
flaglen = 1
if 8 < length <= 16:
flaglen = 2
if length >= 16:
flaglen = 3
flagcon = 0
for i in password:
if i in symbols:
flagcon += 1
break
for i in password:
if i in nums:
flagcon += 1
break
for i in password:
if i in alphas:
flagcon += 1
break
while 1:
print('您的密码安全级别评定为:',end='') # 这里end后面少了个等号
if flaglen == 1 or flagcon == 1:
print('低')
elif flaglen == 3 and flagcon == 3 and (password in alphas):
print('高')
print('请继续保持')
break
else:
print('中')
print('''请按以下方式提升您的安全级别:
1.密码必须由数字、字母及特殊字符三种组合
2.密码只能由字母开头
3.密码长度不能低于16位''')
break {:10_249:}
页:
[1]