三次密码输入
num = 0
while num < 3:Name = input('请输入账号: ')Passwd = input('请输入密码:')if Name == 'kebi' and Passwd == '123':print('登陆成功。')breakelse:print('你还有%d登陆机会' % (2-num))if 2-num == 0:Next = input('你还想再试试吗:Y or N')if Next == 'Y':num = 0continueelse:print('期待与您再次相遇')num +=1
下面是修改之后:
number = 0 while number <3: #多次输入,肯定要循环Name = input('name: ') #账号密码肯定要交互Passwd = input('passwd: ')if Name == 'kebi' and Passwd == '123':print('welcome.')breakelse: #密码不正确之后,没有到0次机会之前打印if number == 2:print("You have entered the error three times")asc = input('You want to try again? you can enter Y to continue:').lower()if asc == 'y':number = 0continueelse:print('Looking forward to meeting with you')else:print('you have %d choice' % (2 - number))number +=1
转载于:https://www.cnblogs.com/yangmingxianshen/p/7698110.html
总结
- 上一篇: PHP中几种加密形式
- 下一篇: Appium 常见API 四(三种等待方