with open('data.json', 'r') as f:
self.cfg = json.load(f)
The above code snippet can read data.json,
The question is, if data.json does not exist, what should I do?
I searched on Google, and most of them introduced with. Unfortunately, my English is not very good, so I may have missed something...
My expectation is:
If data.json does not exist, create and write the default parameters in Json format.
闭关修行中......