从具有多个登录名的文本文件创建登录系统

时间:2019-04-07 21:08:14

标签: python login

我正在尝试建立一个必须通过文本文件验证的登录/注册系统。我将代码放在下面,我可以这样做,以便它记录第一个用户名和密码,但是尝试了一个糟糕的while循环,试图循环遍历文本文件以匹配其他凭据,

>
def Register():
FirstName = input()
Surname = input()
DateOfBirth = input()
Letter1 = FirstName[0]
Letter123 = Surname[0] + Surname[1] + Surname[2]
Number1 = DateOfBirth[-1] + DateOfBirth[-2]
Username = (Letter1 + Letter123 + Number1)
Password = input()

file = open("Credentials.txt", "a")
file.write(Username)
file.write(" ")
file.write(Password)
file.write(" ")

print("Your details have now been saved")

def Login():
Username = input()
Password = input()
while line in open("Credentials.txt","r").readlines():
  login_info = line.split()
  while Username == login_info[0] and Password == login_info[1]:
    if true:
        print ("Correct Login")
    elif Username == login_info[0+1] and Password == login_info[1+1]:
        print("Correct Login")
    else:
        print ("Invalid Login")

0 个答案:

没有答案