• python-login


    Login_1.py

    #!/usr/bin/env python
    #coding:utf-8
    '''
    author:yangying
    filename:xi2.py
    date:17-7-6 下午5:25
    desc:

    '''
    user="root"
    passwd="westos"
    count=0
    while count <4:
        if count==3:
            print ("再见")
            break
        else:
            user_input=raw_input("请输入用户名:")
            passwd_input=raw_input("请输入密码:")
            count += 1
            if user==user_input and passwd ==passwd_input:
                print ("登陆成功!")
                break
            else:
                print ("认证失败,请重新输入  你还有%d机会")%(3-count)

    Login_2.py

    #!/usr/bin/env python
    #coding:utf-8
    '''
    author:yangying
    filename:login_2.py
    date:17-7-7 下午9:55
    desc:

    '''
    users=["mengke",'songzhao']
    passwd=['hello','hello']
    def main():
        str='welcome to user login system'
        a="""
    %s
    (C)reate
    (L)ogin
    Enter choice:"""%str.center(10,'*')
        while True:
            choice=raw_input(a).lower()
            if choice == 'c':
                uname=raw_input("please input name:")
                if uname in users:
                    print '用户已经存在,请直接登陆'
                else:
                    upasswd=raw_input("please input password:")
                    users.append(uname)
                    passwd.append(upasswd)
                    print '用户创建成功'
            elif choice == 'l':
                count=0
                while(count<3):
                    uname = raw_input("please input name:")
                    upasswd = raw_input("please input password:")
                    b=len(users)
                    for i in range (0,b):
                        if uname == users[i] and upasswd == passwd[i]:
                            print '用户登陆成功'
                            exit(0)
                        else:
                            count =count+1
                            print '用户名或密码错误,请重新输入,你还有%d次机会'%(3-count)
                            break
                        print '你已登陆了3次,请半小时后再登陆'
                    else:
                        print '请输入c或l'
    main()

     

  • 相关阅读:
    Android Wear(手表)开发
    Android 中文件类型与MIME的匹配表
    匹配字符串-好技能-正则表达式
    正则表达式匹配字符串
    如何开发Android Wear应用程序
    【转】 hive安装配置及遇到的问题解决
    Hadoop项目开发环境搭建(EclipseMyEclipse + Maven)
    MapReduce 开发环境搭建(EclipseMyEclipse + Maven)
    hive权威安装出现的不解错误!(完美解决)两种方法都可以
    Hive项目开发环境搭建(EclipseMyEclipse + Maven)
  • 原文地址:https://www.cnblogs.com/yangying2017/p/7134428.html
Copyright © 2020-2023  润新知