我的代码有点卡住了我正在尝试创建一个登录系统,用户可以登录到他们的帐户并使用我设置的命令,但我想添加一些额外的输入,以便用户可以注册到登录系统并使用我设置的命令。我想每次都将用户的输入永久存储在不同的变量中,这样当用户重新启动代码时,他们就可以登录系统而无需再次注册。
这是我到目前为止创建的一段代码:
print ("Welcome!")
print ("Would you like to register")
loop = True
while (loop == True):
username = input ("username: ")
password = input ("password: ")
print ("register here if you don't have an account")
username1 = input ("name: ")
print ("this is what you use to login to the system")
username2 = input ("username: ")
username3 = input ("password: ")
if (username == "rohit" and password == "rodude") :
print ("hello and welcome " + username or )
loop = False
loop1 = True
else:
print ("invalid username and password")
while(loop1 == True):
command = str(input(username + "{} > >"))
if(command.lower() == "exit"):
loop1=False
elif(command.lower() == "hi"):
print("Hi " + username + "!")
else:
print ("'" + command + "' is an invalid command!")