Add missing json import

This commit is contained in:
Marcel Ribeiro Dantas 2022-12-01 19:29:50 -03:00 committed by GitHub
parent 7b623a7998
commit 4d6309b2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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