首页 > 编程语言 > 详细

python作业:编写登陆接口

时间:2017-02-12 21:09:40      阅读:289      评论:0      收藏:0      [点我收藏+]

python作业:编写登陆接口

要求:

1.要求用户输入用户名和密码

2.认证成功显示欢迎信息

3.输入错误超过三次锁定用户

 

 1 #!/usr/bin/env python
 2 #_*_coding:utf-8_*_
 3 #__author__ = ‘Administrator‘
 4 
 5 static=True
 6 login=False
 7 username=‘‘
 8 lockfile=rlock.txt
 9 for i in range(3):
10     username=input("please input your username:")
11     password=input("please input your password:")
12 
13     
14     with open(lockfile,r) as lockobject:
15          users=lockobject.readlines()
16          for line2 in users:
17              line2=line2.strip(\n)
18 
19              if line2 == username:
20                  static=False
21                  break
22 
23     if static==False:
24         break
25 
26 
27     with open(ruser.txt,r) as user:
28          users=user.readlines()
29     for line in users:
30         userinfo="|".join([username,password])
31         line=line.strip(\n)
32         if userinfo == line:
33             print(welcome {username} !.format(username=username))
34             login=True
35             break
36 
37     if login:
38         break
39     else:
40          print(Invalid username and password!\n)
41 
42 if login==False:
43     if static:
44         with open(lockfile,a) as lockobject:
45              line_string=‘‘.join([username,\n])
46              lockobject.write(line_string)
47     print("lock!")

 

python作业:编写登陆接口

原文:http://www.cnblogs.com/alstonlee/p/6391699.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!