Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何强制 Python 的 yaml 实现中的 dump() 方法使用每行一个元素的列表样式?
例如,当我做yaml.dump([1,2,3])我"[1, 2, 3]\n"真正想要的时候:
yaml.dump([1,2,3])
"[1, 2, 3]\n"
- 1 - 2 - 3
您可以使用default_flow_style:
default_flow_style
>>> print yaml.dump([1,2,3], default_flow_style=False) - 1 - 2 - 3