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

Python之登陆接口设计

时间:2016-01-11 07:59:31      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

刚刚开始学习Python,第一个编写的程序。

技术分享
import os

user_file = open(use_file.txt, r)
user_list = user_file.readlines()
user_file.close()
while True:
    lock_file = open(lock_file.txt, r+)
    lock_list = lock_file.readlines()
    lock_file.close()

    login_Success = False
    user_name = input((user:).strip())
    for line1 in lock_list:
        line1 = line1.split()
        if user_name == line1[0]:
            print("Sorry, you are already in the block list, get the fucking out!")
            exit()
    for line2 in user_list:
        line2 = line2.split()
        if user_name == line2[0]:
            for i in range(3):
                password = input((Password:).strip())
                if password == line2[1]:
                    print("Welcome %s login my system!" % user_name)
                    login_Success = True
                    break
            else:
                f = open(lock_file.txt, a)
                f.write(%s\n % user_name)
                f.close()
                print("Entered 3 times of wrong passwd, going to lock %s" % user_name)
            if login_Success == True:
                break
    if login_Success == True:
        break
View Code

 

Python之登陆接口设计

标签:

原文地址:http://www.cnblogs.com/ouyangyixuan/p/5120088.html

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