0

I am creating a short text based game and am stuck on saving data in files so when the file is opened again the game can be continued with current stats etc.

I have already made it so when a new file is created text is saved in the format of a dictionary, so upon opening the file it is transferred to an in-code dictionary using (dict) = json.loads (text from file)

But I don't know how to get the variables back into the file

Thanks

Sneaki
  • 1
  • 2
    Use `pickle` not .txt to save python variables. Read here https://docs.python.org/3/library/pickle.html – Epsi95 Jan 27 '21 at 13:43
  • 1
    take a look into pickle: https://docs.python.org/3/library/pickle.html IMO it will save you a lot of headaches as a beginner and you can focus on the actual game that you are writing. – 0x6d64 Jan 27 '21 at 13:44

0 Answers0