summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--python.html.markdown1
1 files changed, 1 insertions, 0 deletions
diff --git a/python.html.markdown b/python.html.markdown
index 2247f263..175f17ec 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -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