From 4d6309b2bde3c927691b15d049ef7a31c678e1f1 Mon Sep 17 00:00:00 2001 From: Marcel Ribeiro Dantas Date: Thu, 1 Dec 2022 19:29:50 -0300 Subject: [PATCH] Add missing json import --- python.html.markdown | 1 + 1 file changed, 1 insertion(+) 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