Question

Voici comment se comporte PyYAML sur ma machine:

>>> plan = {'Business Plan': ['Collect Underpants', '?', 'Profit']}
>>> print(yaml.dump(plan))
Business Plan: [Collect Underpants, '?', Profit]

Ce que je veux est au contraire cette sortie (les deux est YAML valide):

Business Plan:
- Collect Underpants
- '?'
- Profit

Y at-il une sorte d'option qui le ferait?

Était-ce utile?

La solution

Vous devez ajouter l'argument 'default_flow_style = False' à l'appel:

In [6]: print(yaml.dump(plan, default_flow_style=False))
Business Plan:
- Collect Underpants
- '?'
- Profit
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top