我正在尝试创建一个登录系统。我可以在不实现类和函数的情况下制作系统。我想将每个步骤都变成特定的方法,而不是全部写入一个函数。
我的问题是如果字符长度> 5或密码错误,如何恢复登录询问用户名和密码。
如果用户名和密码不在列表中,我该如何将其恢复或需要再次编码?
class LoginSystem:
def __init__(self):
self.user_id = input("Please enter your user id: ")
self.user_password = input("Please enter your password: ")
def login(self):
username = self.user_id
password = self.user_password
if len(username) <= 5 and len(password) <= 5:
print("Logging In")
else:
print("Error! Max Length is 5 chars.") #return back to
login system
def check_system(self):
registered_user = {
"test@gmail.com": "test"
}
if self.user_id in registered_user:
print("Successful")
else:
new_user = input("Id not found! Are you are new user?\n [Y]es or [N]o\n")
new_user = new_user.lower()
if new_user == "Y":
return back to login system
elif new_user == "N": #how to return back to main login system
new_username = input("Please enter your user id: ")
new_userpassword = input("Please enter your password: ")
else:
return #back to login system
幕布斯7119047
相关分类