2010-02-20 2 views
0

Voici comment PyYAML se comporte sur ma machine:Modifier la mise en forme de liste dans la production PyYAML

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

Ce que je veux est plutôt cette sortie (les deux est YAML valide):

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

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

Répondre

1

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 
+0

Merci! Fonctionne parfaitement. –

Questions connexes