0
I’m running a registration system, which records a person’s user and password in a dictionary and then passes that dictionary to a .txt. See the example:
user = 'Lucas'
password = '1234'`
dic = {}
dic[user] = password`
import pickle
archive = open('data.txt', 'ab')
pickle.dump(dic, archive)
archive.close()`
archive = open('data.txt', 'rb')
dic = pickle.load(archive)
archive.close()
print(dic)
The problem is that my program will register infinite users and forever, so if I now put another user and another password it should return a dictionary with all registered users + the user being registered, that is, add the last entry to the already saved dictionary with previous users, only that it is saving a dictionary only with the last registered user. How could you solve?
You are always defining a new dictionary,
dic
. To do this, you will need to load the dictionary from the file before entering the new registration.– Woss
How could I do that Woss?
– Skudy009
You’ve already done it in the code, just analyze and understand well what you wrote in the code.
– Woss