Hey!
So for ex36 I wanted to try and make a mock up game where a mechanic in it is that the program remembers how many times you have opened the game (and will say things based on how many times you opened it, smth like a narrator that keeps getting annoyed because you wake it up when opening the program).
I did some research on how to import and change a specific variable in a separate file, and came to the conclusion that the best option for me is using json files.
Now, I did some research on dicts and with
and as
and in general loading and dumping to json files, but I get error that I tried fixing but canât seem to.
in my python file (testing.py)
import json
with open('config', 'w+') as config_file:
json.load(config_file)
And in my json file (config.json)
{"restarted": 0}
The error:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
When i tested working with loads() and dumps() I didnât have a problem, but somehow if its a file and not string I canât even load the data.
tldr:
My goal is getting a value from a json file, and consequently being able to change and dump it back again.
Would really appreciate some help