一个简单的python登录验证系统

希望大家来指正一下,之前间断学习了很久,刚捡起来继续学习,下面的代码写的不太好,希望看到的大神能够给予指正。

 1 # python_zhangzengqiang
 2 
 3 a = open("login.txt")
 4 b = a.readlines()
 5 a.close()
 6 a2 = open("lock.txt")
 7 b2 = a2.readlines()
 8 a2.close()
 9 loginsucess = False
10 while True:
11     username = input("请输入账号::").strip()
12     for i2 in b2:
13         i2 = i2.split()
14         if username == i2[0]:
15             print("您的账号已被锁定!")
16             exit()
17     if  len(username) != 0:
18         for i in b:
19             i = i.split()
20             if username == i[0]: 
21                 for x in range(3):
22                     password = input("请输入密码:").strip()
23                     if password == i[1]:
24                         loginsucess = True
25                         break
26                 else:
27                     print("连续输入密码失败超过3次,账号已被锁定登录!")
28                     a1 = open("lock.txt","a")
29                     a1.write(username+"\n")
30                     a1.close()
31         if loginsucess is True:
32             print("登录成功,欢迎回家!")
33             break
34         elif loginsucess is False:
35             print("用户名错误,请重新输入!")
36     else:
37         continue

猜你喜欢

转载自www.cnblogs.com/zhangzengqiang/p/9141538.html