Created
May 1, 2021 15:11
-
-
Save tomschr/86a8c6f52b81e35ac4723fef8435ec43 to your computer and use it in GitHub Desktop.
Revisions
-
tomschr created this gist
May 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # Source # Mastering Object-Oriented Python - Second Edition by Steven F. Lott Published by Packt Publishing, 2019 # https://learning.oreilly.com/library/view/mastering-object-oriented-python/9781789531367/c34be237-5ccd-4775-a0b0-ec1f7652f7bc.xhtml # from pathlib import Path # write JSON files: with Path("temp.json").open("w", encoding="UTF-8") as target: json.dump(travel3, target, default=blog_j2_encode) # read JSON files: from pathlib import Path with Path("some_source.json").open(encoding="UTF-8") as source: objects = json.load(source, object_hook=blog_decode)