Created
March 8, 2018 20:35
-
-
Save chulman444/62729a74e426fe4e170ff36d4d8cf785 to your computer and use it in GitHub Desktop.
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 yaml | |
content = """First line | |
Second line | |
Third line""" | |
print("The following is the content") | |
print(content) | |
print("-------------END of content") | |
print("\nThe following is when you dump it") | |
print(yaml.dump(content)) | |
print("-------------END of dump") | |
print("\nThe following is when you load, say, a file with the content") | |
print(yaml.load(content)) | |
print("-------------END of load") | |
# OUTPUT: | |
""" | |
The following is the content | |
First line | |
Second line | |
Third line | |
-------------END of content | |
The following is when you dump it | |
'First line | |
Second line | |
Third line' | |
-------------END of dump | |
The following is when you load, say, a file with the content | |
First line | |
Second line | |
Third line | |
-------------END of load | |
""" |
What I have so far
loaded = yaml.load(file_content)
lines = loaded.split("\n")
fixed_str = ""
for line in lines:
# Add 2 empty spaces ' ' + ' ' at the beginning of a line
# Add 3 new lines at the end of a line
fixed_str = " " + line + "\n\n\n"
# load AGAIN
fixed_str = yaml.load(fixed_str)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New lines are killing me.
I didn't have to read "JSON reference", but I guess I'll have to give "YAML reference" (here) a try, not knowing understanding the 'reference' could help me out.