#!/user/bin/python# -*- coding:utf-8 -*-#当剩余为0次机会时、询问用户是否再试试、如果同意那就再给三次机会、可一直继续username = 'zd'password = '123'i = 0while i < 3 : name = input('用户名:') pwd = input('密码:') if username == name and password == pwd : print('登陆成功') break else: print('登陆失败,还有%d次机会' %(2-i)) if (2-i) == 0 : result = input('是否再试试?yes') if result == 'yes': i = 0 continue i += 1else: print('不要脸')