码迷,mamicode.com
首页 > 编程语言 > 详细

python3.5------用户的三次验证

时间:2016-10-22 18:21:24      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:img   ref   inline   技术   else   逻辑   log   src   str   

笔者QQ: 360212316

逻辑图

技术分享

代码

#/usr/bin/python
# -*- coding: utf-8 -*-

lock = open("black_user_list.txt", a, encoding=utf-8)
lock.write("\n")
user_list = open("userlist.txt", w+, encoding=utf-8)
user_list.write("zhangsan\n")
user_list.write("lisi\n")
user_list.close()
user_list = open("userlist.txt", r, encoding=utf-8)
white_username = user_list.read().strip()
user_list.close()
lock = open("black_user_list.txt", r+, encoding=utf-8)
lock_username = lock.read().strip()
while True:
    username = input("username:")
    if username in lock_username:
        print("\033[31;1m %s Account lockout \033[0m" % username)
        break
    elif username in white_username:
        for i in range(2, -1, -1):
            password = input("password:")
            if password == abc123:
                print("Welcome to log on %s" % username)
                break
            else:
                print("\033[31;1mPassword remaining: \033[0m %s" % i)
                if i == 0:
                    print("\033[31;1m %s Account lockout \033[0m" % username)
                    lock.write("\n")
                    lock.write(username)
                    lock.close()
                    exit()
    else:
        print("Account does not exist")

python3.5------用户的三次验证

标签:img   ref   inline   技术   else   逻辑   log   src   str   

原文地址:http://www.cnblogs.com/alber/p/5987825.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!