Convert Python dictionary to yaml

Convert Python dictionary to yaml

By default, PyYAML chooses the style of a collection depending on whether it has nested collections. If a collection has nested collections, it will be assigned the block style. Otherwise it will have the flow style.

If you want collections to be always serialized in the block style, set the parameter default_flow_style of dump() to False. For instance,

> `print(yaml.dump(yaml.load(document), default_flow_style=False))`
>> Result: `a: 1 b:   c: 3   d: 4`

Documentation: https://pyyaml.org/wiki/PyYAMLDocumentation

Convert Python dictionary to yaml

Leave a Reply

Your email address will not be published.