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

Python 编写登陆接口,输入用户名密码,认证成功后显示欢迎信息,输入错误三次锁定

时间:2015-04-29 17:38:18      阅读:587      评论:0      收藏:0      [点我收藏+]

标签:python

file = open(‘lock.txt‘).readlines()
name = input(‘username:‘).strip()
lock=[]
for i in file:
     line = i.strip(‘\n‘)
     lock.append(line)
if name in lock:
     print(name,‘已经被锁定,请联系开户行.退出!‘)
else:
     i = 1
     while i <=3:
            i = i + 1
            print(‘........................‘)
            username = name
            print (username)
            passwd = input(‘Passwd:‘).strip()
            f = open(‘user.txt‘, ‘r‘)
            login = False
            if len(username) != 0 and len(passwd) != 0:
                  for line in f.readlines():
                        if username == line.split()[0] and passwd == line.split()[1] :
                              print("欢迎中国银行AMT系统")
                              login = True
                              break
                        else:
                              continue
            if login is True:
                              break
     else:
            f = open(‘lock.txt‘, ‘a‘)
            f.write(name)
            f.write(‘\n‘)
            f.close()
            print(name,‘你的密码输入超过三,锁定帐号,退出‘)

本文出自 “强哥博客” 博客,请务必保留此出处http://listcto.blog.51cto.com/10175308/1640312

Python 编写登陆接口,输入用户名密码,认证成功后显示欢迎信息,输入错误三次锁定

标签:python

原文地址:http://listcto.blog.51cto.com/10175308/1640312

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