Я собираюсь использовать систему входа в систему. Пожалуйста, скажите, если я объявил переменную для своего текстового файла (базы данных)
# Global Variables (few are inside function)
global data
global l_password
global wrong
# The Main Thing
def system():
choose = input("Enter 'c' to create an account \n\t\tor \nEnter 'l' to log in \n\nEnter here: ")
if choose == "c":
create()
print("Now please login with your created account")
login()
elif choose == "l":
login()
else:
print("You have entered and invalid character. \nPlease enter only 'c' or 'l' ")
# Creating an account
def create():
c_username = str(input("Username: "))
c_password = str(input("Password: "))
data = open("accounts_data", "a")
data.write("\n\nUsername: ")
data.write(c_username)
data.write("\nPassword: ")
data.write(c_password)
print("Success! Account is created.")
# Logging in an account
def login():
print("Login with your account ---->")
l_username = str(input("Username: "))
l_password = str(input("Password: "))
if l_username or l_password in data.read():
print("Congrats! You are successfully now logged into your account!")
if l_username or l_password not in data.read():
error = str(input(
"Sorry we couldn't find your account. "
"\nEnter the correct username or password."
"\n\tor \nType 'r' to retry \nor \nCreate one by typing 'c'\n:"))
if error == 'r':
login()
elif error == 'c':
create()
login()
system()
data.close()
Он говорит, что оба, вошли в учетную запись, а также извините, не смогли найти учетную запись
if l_username or l_password in data.read():
print("Congrats! You are successfully now logged into your account!")
if l_username or l_password not in data.read():
error = str(input(
"Sorry we couldn't find your account. "
"\nEnter the correct username or password."
"\n\tor \nType 'r' to retry \nor \nCreate one by typing 'c'\n:"))
МОЙ ТЕКСТОВЫЙ ФАЙЛ (где хранятся все эти учетные записи, а переменная является данными для этого файла) Скажите, пожалуйста, если я объявил переменную для этого файла
в моем текстовом файле все это есть. Правильно?
Username: apple
Password: apples