相关疑难解决方法(0)

保留YAML中的新行

如何格式化这样的YAML文档,以便PyYAML可以正确解析它?

Data: Some data, here and a special character like ':'
      Another line of data on a separate line
Run Code Online (Sandbox Code Playgroud)

我知道':'字符是特殊的所以我必须用引号括起整个东西:

Data: "Some data, here and a special character like ':'
      Another line of data on a separate line"
Run Code Online (Sandbox Code Playgroud)

为了添加新行,我必须添加'\n':

Data: "Some data, here and a special character like ':'\n
      Another line of data on a separate line"
Run Code Online (Sandbox Code Playgroud)

有没有格式化YAML文档,所以我不必添加\n's以便有一个新行?

yaml pyyaml

20
推荐指数
2
解决办法
7910
查看次数

标签 统计

pyyaml ×1

yaml ×1