I am trying to make a simple project where you can save "money" and spend "money" however I want this data to be stored in a more reliable place then just a normal python variable. I would also like it to be stored preferably in a .txt file with a formatting a bit like:
account1
1000
account2
129
with the number representing the amount of money.
I have tried using json.dumps however I couldn't find a way to get a certain accounts "money" (like fetching the money connected to the account specified).
If you have the data inside a dictionary you could simply use this to store it inside a file:
data = {'key':'value1','key2':'value2'}
file = open('info.txt', 'w')
file.write(str(data))
file.close()
Hope this helps.