Home > OS >  How to create a local storage for a python desktop application?
How to create a local storage for a python desktop application?

Time:06-22

i want to create a desktop application that will take an input (email and password) and store it for later use in my tkinter app. How can i store this data in a secure way on the user's end so on their laptop locally where i can access it every time the user opens the application it will auto sign them in. i don't want to create a server on my end or make a website or a database.

i just want to store the data locally with python and have access to it in a secure way.

thx in advanced :)

CodePudding user response:

Save the data:

import json
data = {"username":"username","password":"123"}
with open('data.json', 'w ') as outfile:
    json.dump(data, outfile, indent=4) 

Open the data

import json
with open("data.json") as file:
  data = json.load(file)

this will save all the stuff in the data dictionary and you'll be able to access it from a file called data.json in the same directory of the python file.

  • Related