Last active
March 6, 2024 12:37
-
-
Save BedirYilmaz/dc8c6b55a4224c69bda2aa9a78f893ed to your computer and use it in GitHub Desktop.
creation of json file whose content are the elements of a list
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 characters
import json | |
li = ["Yet each man kills the thing he loves,", | |
"By each let this be heard,", | |
"Some do it with a bitter look,", | |
"Some with a flattering word,", | |
"The coward does it with a kiss,", | |
"The brave man with a sword!", | |
"Some kill their love when they are young,", | |
"And some when they are old;", | |
"Some strangle with the hands of Gold:", | |
"The kindest use a knife, because", | |
"The dead so soon grow cold.", | |
"Some love too little, some too long,", | |
"Some sell and others buy;", | |
"Some do the deed with many tears,", | |
"And some without a sigh:", | |
"For each man kills the thing he loves,", | |
"Yet each man does not die."] | |
out_file_path = "path/to/file.json" | |
with open(out_file_path, "w") as file_out: | |
json.dump(li, file_out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment