python_登录实例

#coding=utf-8
username = "baidu"
password = "123"
i = 0
while i<3:
     name = input("请输入你的用户名:")
     pwd = input("请输入你的密码:")
     if username ==name and pwd ==password:
        print("登陆成功")
        break
     else:
        print("登录失败,您还有%d次登录机会"%(2-i))
        if(2-i)==0:
            result = input("请问您是否还想再试试[y/n]")
            if result == 'y':
                i=0
                continue
     i+=1
else:print("不要脸")#没有break就执行这个

 

posted @ 2018-08-23 09:12  王学长  阅读(191)  评论(0编辑  收藏  举报