I’m writing a program that allows the user to create a username and password. How do I write this as a dictionary into a text file, and then retrieve it when I need it? Also, if there is an easier way to do this I’m welcome to any new ideas.
Share
Use Python serialization mechanism – pickle.
Small example:
Now you can easily save content of
sto some file. After that you can read it and decode:But this approach is not quite safe. Don’t use it for dangerous data or data that you rely on.
Check out “Why Python Pickle is Insecure” by Nadia Alramli.