I am attempting to update a YAML file where I have a series of key, value pairs that look like
key:
'A': 'B'
'C': 'D'
I clear the file with f.truncate(0)
and then dump a dictionary back but when dumping the dictionary the key,values don't have the string quotes between key-value pairs. How would I get the dump back to the file to render string quotes?
edit: adding code
with open(filepath, "r+") as f:
d = yaml.unsafe_load(f)
# edit dictionary
# clear file
f.seek(0)
f.truncate(0)
yaml.dump(d, f, default_flow_style=False, sort_keys=False)