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()
  • 相关阅读:
    第三章 熟悉常用的HDFS操作
    爬虫大作业
    数据结构化与保存
    使用正则表达式,取得点击次数,函数抽离
    爬取校园新闻首页的新闻
    网络爬虫基础练习
    综合练习,词频统计
    Hadoop综合大作业
    理解MapReduce
    熟悉常用的HBase操作
  • 原文地址:https://www.cnblogs.com/ne-zha/p/7143553.html
Copyright © 2011-2022 走看看