T
T
TheAmmiR2018-10-15 19:33:49
Python
TheAmmiR, 2018-10-15 19:33:49

How to write a program that remembers the data entered earlier and uses it?

Briefly speaking. First, I will write the question in more detail, then I will go into "well, in general, how I think this should be done."
Suppose there is a simple if-elif program, which, depending on the entered password, displays some information by type

login = str(input("Введите логин: "))
password = str(input("Введите пароль: "))

if (login == 'TheAmmiR') and (password == 'mysecretpassword'):
    print("Рады вас приветствовать, администратор интернет-магазина \"Утюг\".")
elif (login == 'User') and (password == 'none'):
    print("Рады вас приветствовать в нашем интернет-магазине!")
else:
    print("Неправильно введенный логин или пароль.")

And now such a task. How to register, according to the principle of the same ...
login = str(input("Enter your login: "))
password = str(input("Enter your password: "))
..?
At the same time, it will be remembered, and it can be used in the authorization process.
In my opinion, you should create a text document in which logins and passwords will be stored in a certain format. But how then to use them in the program itself? Tell me, who knows, maybe there are still separate libraries or modules for these purposes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Solod, 2018-10-15
@Potter

The easiest way is probably to read from the same text file.with open(file, 'r') as f:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question