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.
每个 to_yaml 输出都有三个前导破折号:
--- a: b: c: soemthing
如何在没有前导破折号的情况下将对象转换为 yaml?
来自YAML 规范:
YAML 使用三个破折号(“---”)将指令与文档内容分开。如果不存在指令,这也用于指示文档的开始。
这意味着:您的示例应以有效的 YAML 文档开始。它没有错。