我目前正在为我的实践开发一个桌面登录注册应用程序,但在登录和注册方面遇到了一些问题。如果我REGISTER
在命令中输入并添加我的信息,f.write()
它会存储我的信息,但之后一切都会正常,就像整个文件被格式化一样(这是寄存器问题)。
登录问题是如果我想检查文件中的名称或密码是否存在(此命令可能是错误的)。我尝试使用,if login_email and login password in f:
但它说不login_email
存在password
。
代码:
f = open('pass.txt', 'w')
fr = open('pass.txt', 'r')
from time import sleep
login_list = "LOGIN"
register_list = "REGISTER"
if 1 > -3232:
print("Type register for new account\ntype login for login into existing account")
bi = input("==> ")
if bi.upper() in login_list:
print("you are registered?? nice now loginnn!!")
login_1 = input("your username: ")
login_2 = input("your password: ")
if login_1 and login_2 in fr:
print("Nice my program worked??")
exit()
else:
exit()
elif bi.upper() in register_list:
print("you are in register section: ")
sleep(.9)
print("NOTE: Your password should only contain alphabets!")
sleep(4)
reg_1 = input("your username: ")
sleep(.9)
reg_2 = input("your password: ")
sleep(.9)
reg_2v1 = input("confirm password")
if reg_2 == reg_2v1:
f.write(reg_1 + " : " + reg_2 + "\n")
print("now login again,\")
else:
print("invalid password, try again")
else:
print("you gave me the wrong command")
else:
exit()
有只小跳蛙
相关分类