mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Add missing json import
This commit is contained in:
parent
7b623a7998
commit
4d6309b2bd
@ -503,6 +503,7 @@ contents = {"aa": 12, "bb": 21}
|
||||
with open("myfile1.txt", "w+") as file:
|
||||
file.write(str(contents)) # writes a string to a file
|
||||
|
||||
import json
|
||||
with open("myfile2.txt", "w+") as file:
|
||||
file.write(json.dumps(contents)) # writes an object to a file
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user