ruamel.yaml:修改dump()以添加额外的' - '劈头

时间:2017-11-27 09:54:47

标签: python yaml pyyaml

我使用ruamel.yaml库将字典转储到yaml文件中。然而,它并没有像我喜欢的那样表现。

我怎么能得到:

---
- a: 
    - foo: bar
    - bar: foo

而不是:

a:
    - foo: bar
    - bar: foo

yaml.dump()

我从以下网站提取数据:

data = {
    'a': [
         {'foo':'bar'},
         {'bar':'foo'}
       ]
     }

任何其他具有相同功能的库都可以提交。

0 个答案:

没有答案