zoukankan      html  css  js  c++  java
  • day1-登录系统

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    import getpass
    file=open('passwd.txt','r',encoding='utf-8')
    filewrong=open('passwd_wrong.txt','r',encoding='utf-8')
    login_pwd=eval(file.read())
    login_wrong=eval(filewrong.read())
    file.close()
    filewrong.close()
    i=1
    list=[]
    list=login_wrong
    login="err"
    while i<=3 :
        account = input("Account:")
        password = getpass.getpass("password;")
        if account in login_wrong:
            print("user locked!!")
        else:
            for i2 in range(len(login_pwd)):
                if account == login_pwd[i2][0]:
                    login="user"
                    if password == login_pwd[i2][1]:
                        print("login success!")
                        login="success"
                        break
                    else:
                        print("Try Again!!You only have %d chances left." % (3 - i))
                        i+=1
                else:
                    login="nouser"
            if login=="nouser":
                print("user:%s no exit!!" % account)
            if login=="success":
                break
    else:
        print("user locked!!")
        filewrong=open('passwd_wrong.txt','w',encoding='utf-8')
        list.append(account)
        print(str(list))
        data=str(list)
        filewrong.write(data)
        filewrong.close()

    文件1 passwd.txt

    [["abc123","password"],["aaa","bbb"]]

    文件2 passwd_wrong.txt

    ['abc123']

    二 . 笔记记录下代码实现过程

  • 相关阅读:
    mybatis中crud操作范例
    Guava----Function
    Spring mvc Controller接口
    简单的验证码识别(opecv)
    Mat转换为QImage
    将多张图片无缝拼接方法
    模式识别---图像二值化
    双边过滤算法
    C++对于大型图片的加载缩放尝试
    ijg库解码超大型jpeg图片
  • 原文地址:https://www.cnblogs.com/a10086/p/9216945.html
Copyright © 2011-2022 走看看