我遇到了一个问题,我有一些代码来启动一个菜单系统的事情,我一直在做,无论用户名和密码是正确的,它只是不会注册他们是平等的
def passw():
f=open("userpass.txt","r")
a=linecache.getline('userpass.txt',1)
a=str(a)
c=linecache.getline('userpass.txt',2)
c=str(c)
f.close()
print(a+c)
if a == "" and c == "":
f=open("userpass.txt","a")
user=input("Please enter a username: ")
f.write(user)
f.write("\n")
password=input("Please enter a password: ")
f.write(password)
f.close()
menumain()
elif a != "" and c != "":
f=open("userpass.txt","r")
user=linecache.getline('userpass.txt',1)
user=str(user)
user=user[0:-1]
rpass=linecache.getline('userpass.txt',2)
rpass=str(rpass)
print(user,rpass)
f.close()
time.sleep(0.5)
while True:
inputUser = str(input("Enter your username: "))
inputPass = str(input("Enter your password: "))
if inputUser == user and inputPass == rpass:
menumain()
else:
print("Incorrect username or password")
目前没有回答
相关问题 更多 >
编程相关推荐