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

用户登陆程序(python3.x)

时间:2018-06-17 19:00:53      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:input   ext   readline   div   com   system   信息   lines   ros   

程序要求:
   1.输入用户,如果没有注册,先注册

  2.认证成功先是欢迎信息

  3.输错三次后锁定

 1 username = input("username:")
 2 #判断用户被锁了
 3 with open("lock.txt",r+) as l:
 4     lockname=l.readlines()
 5     if username in lockname:
 6         print ("you user is locked,you can not login,plese you go to  unlock...")
 7         exit()
 8     else:
 9         print ("you user unlock,plese next...")
10 
11 #判断用户是否注册,如果注册进行登陆,没有注册则进行注册
12 for i in range(2):
13     with open("register.txt",r+) as f:
14         regname=f.readlines()
15         if username in regname:
16              print("your user have registed........plese logining...")
17              break
18         else:
19              print("this system have not your user,you must to regist....")
20              with open("passwd.txt",r+) as p:
21                 reguser = input("reguser:")
22                 regpasswd= input("regpasswd:")
23                 f.writelines(\n)
24                 f.writelines(reguser)
25                 p.writelines(\n)
26                 p.writelines(regpasswd)
27 
28 #进行登陆
29 loginname=input("loginname:")   ##这个name与注册的是相同的
30 for i in range(3):
31     loginpasswd=input("loginpasswd:")
32     with open("passwd.txt",r+) as w:
33          passwd=w.readlines()
34 
35          if loginpasswd in passwd:
36             print ("welcome to here....")
37             break
38          elif i<2:
39             print ("your passwd is false...plese try agin...")
40          else:
41             print ("you have tried three times,your user have locked")
42             #向锁文件添加用户
43             with open("lock.txt",a+) as k:
44                 k.writelines(\n)
45                 k.writelines(loginname)

用户登陆程序(python3.x)

标签:input   ext   readline   div   com   system   信息   lines   ros   

原文地址:https://www.cnblogs.com/summer-future/p/9193336.html

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