문제

This is how PyYAML behaves on my machine:

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

What I want instead is this output (both is valid YAML):

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

Is there some kind of option that would do it?

도움이 되었습니까?

해결책

You need to add the 'default_flow_style=False' argument to the call:

In [6]: print(yaml.dump(plan, default_flow_style=False))
Business Plan:
- Collect Underpants
- '?'
- Profit
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top