zoukankan      html  css  js  c++  java
  • python日记(一)简单的密码登录

    # readme:
    #     blogger address:www.cnblogs.com/ne-zha
    #     ne_zha
    #     要求:
    #     编写登陆接口
    #     1.输入用户名密码
    #     2.登录成功显示欢迎信息
    #     3.输错三次锁定
    
    
    lock_file=open('file_lock.txt','r')
    user_pass=open('username_file.txt','r')
    
    cmd =int(input('''
    登录系统输入1
    退出系统输入2
    请输入操作:
     '''))
    if cmd ==2:
        exit()
    elif cmd ==1:
        username = input("please input your user...")
        for i in range(3):
            for i in lock_file.readlines():
                i = i.split()
                if username in i[0]:
                    print('对不起 %s 已锁定' % username)
                    exit()
        match = False
        for j in user_pass.readlines():
            user,passwd =j.split()
            if username ==user:
                password =input("please input the passwd")
                if password ==passwd:
                    print("登录成功!")
                    match = True
                    break
                elif password !=passwd:
                    for n in range(2):
                        password =input("密码错误,请重新输入!")
                        if password ==passwd:
                            print("登录成功!")
                            match = True
                            break
        if username !=user:
            print("用户名不存在!")
            exit()
        if match ==False:
            print("三次输入错误,账户以被锁定!")
            lock_file.write('%s 
    ' % username)
            lock_file.close()
            user_pass.close()
            exit()
  • 相关阅读:
    关于swift 单元测试的补充
    架构设计案例分析-高速公路收费运营管理平台
    可以落地的软件架构
    循序渐进地培养面向对象的思维方式
    动态规划初学
    求解惑
    github eclipse项目
    关于x86 i586之类
    Manifest intent filter翻译
    消息处理机制小结
  • 原文地址:https://www.cnblogs.com/ne-zha/p/7143553.html
Copyright © 2011-2022 走看看