Created
March 11, 2021 23:29
-
-
Save SamSaffron/9c0b78a1e5e3eabe96372725ec230daa to your computer and use it in GitHub Desktop.
This file contains 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
from ruamel.yaml import YAML | |
import sys | |
example = """ | |
# hello | |
test: "test\\ntest\\ntest" # a test | |
test2: hello.. #world | |
""" | |
rt_yaml=YAML(typ='rt') | |
parsed = rt_yaml.load(example) | |
parsed['world'] = "hello" | |
parsed['test2'] = "test2" | |
rt_yaml.dump(parsed, sys.stdout) | |
# output: | |
# # hello | |
# test: "test\ntest\ntest" # a test | |
# test2: test2 #world | |
# world: hello | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment