三次密码输入
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 四(三种等待方