zoukankan      html  css  js  c++  java
  • 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()

     

  • 相关阅读:
    C# 移除string[] 数组中的指定元素
    传入一个字符串参数 获取这个字符串内所有字符的 不同排列情况
    js 更新本地当前时间
    js 通过单选框 展开和收缩 下拉框
    js 做加法
    js 验证 输入的值是否为整数
    用一个button控件调用fileupload控件的获取路径功能
    删除表中的多余的记录
    实验楼 实现课程模块
    微博回调接口(django)
  • 原文地址:https://www.cnblogs.com/yangying2017/p/7134428.html
Copyright © 2011-2022 走看看