python - add new field to yaml file using ruamel.yaml adds extras new line - Stack Overflow

Original filecontrols:- id: AC-1levels:- high- moderate- low- id: AC-2When i add a new field to mappi

Original file

controls:
- id: AC-1
  levels:
  - high
  - moderate
  - low

- id: AC-2

When i add a new field to mapping, it looks like this, rules is the new added field.It adds a new extra new line.

controls:
- id: AC-1
  levels:
  - high
  - moderate
  - low

  rules: []
- id: AC-2

But i want this, is this possible.

controls:
- id: AC-1
  levels:
  - high
  - moderate
  - low
  rules: []

- id: AC-2

I saw there is a similar question Modifying YAML using ruamel.yaml adds extra new lines, but i believe this is very old.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744217872a4563638.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信