zoukankan      html  css  js  c++  java
  • Python 用户输入用户名,进行验证

    Python 征程(用户输入名字进行密码验证)

    #!/usr/bin/env python
    
    account_file = file('account.txt')
    user_list = account_file.readlines();
    
    
    while True:
        lock_file = file('lock.txt')
        lock_list = []
        for line in lock_file.readlines():
            lock_list.append(line.strip('
    '))
    
        username = raw_input('username:').strip()
    
        print lock_list
    
        if username in lock_list:
            print 'sorry %s are in black list!' % username
            exit(0)
        if len(username) == 0:
            print 'user can not empty'
        else:
            for line in user_list:
                if username == line.split()[0]:
                    for i in range(3):
                        password = raw_input('password').strip()
                        for line in user_list:
                            if password == line.split()[1]:
                                print 'Welcome %s to my system !' % username
                                exit(0)
    
                    print 'password has incorrent three times' 
                    lock_file = file('lock.txt','a') 
                    lock_file.write('
    %s' % username)
                    lock_file.close()
                    break
            print '%s are not in system account' % username 
    

     文件account.txt(用户保存文件)

      luowen admin

      admin 123

    文件 lock.txt(黑名单文件)

      

  • 相关阅读:
    C#=>递归反转栈
    C#=> 栈模仿堆的操作
    C# 栈=>随时读取栈中最小值
    vijos1574 摇钱树
    (二叉)堆
    分块大法好
    list
    动态规划——状压、树形
    区间动规平行四边形优化
    最长公共子序列(LCS)
  • 原文地址:https://www.cnblogs.com/luowen/p/python.html
Copyright © 2011-2022 走看看