import yaml data = dict( A = 'a', B = dict( C = 'c', D = 'd', E = 'e', ) ) with open('data.yml', 'w') as outfile: yaml.dump(data, outfile, default_flow_style=False)
The parameter default_flow_style=False necessary to create the desired format (stream style), otherwise it creates a block style for nested collections:
A: a B: {C: c, D: d, E: e}
Matthew Trevor Sep 18 2018-12-12T00: 00Z
source share