本帖最后由 汤加里罗雪顶甜 于 2020-5-8 19:09 编辑 ID = 'ilove'
Password = 'fishc.com'
times = 0
while times <= 3:
IDinput = input('请输入登录账号:')
Passwordinput = input('请输入登录密码:')
if ID == IDinput and Password == Passwordinput:
print ('欢迎登录我们的网站!')
print ('读取信息中.......')
print ('空!')
print ('正在退出中.....')
break
else:
print ('您输入的账号或密码错误,您还有',3-times,'次机会')
print ('请重新输入!')
times += 1
if times > 3:
print ('登录次数用尽,请稍后再试!')
print ( 'end'.center(20).translate(str.maketrans(' ','-')))
for times in range(0,4):
IDinput = input('请输入登录账号:')
Passwordinput = input('请输入登录密码:')
if ID == IDinput and Password == Passwordinput:
print ('欢迎登录我们的网站!')
print ('读取信息中.......')
print ('空!')
print ('正在退出中.....')
break
if times == 3:
print ('登录次数用尽,请稍后再试!')
else:
print ('您输入的账号或密码错误,您还有',3-times,'次机会')
print ('请重新输入!')
print ( 'end'.center(20).translate(str.maketrans(' ','-')))
给出的参考答案里面就算“成功登录了,还是会print“登录次数用尽,请稍后再试!”,不太合适吧。 |