← Back to Files
Question 428
Settings On Disk
Settings On Disk
Save the settings dict to settings.json with json.dump and indent=2. Then open the file for reading, read the raw text with f.read() and print it (the file ends without a newline, so a plain print supplies the one that ends the last line); decode the same text with json.loads into loaded and print Theme: <theme> on the next line. There is no input. Notice how Python's True is stored as true in the file. Import only json.
Expected Output:
{ "theme": "dark", "font_size": 14, "autosave": true } Theme: dark
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
FilesJSON
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.