我想这样做
test: >
This is a long string
\n\n\n
with new lines
但它会打印出“\n”而不是换行。
我知道这是可能的
test: "This is a long string
\n\n\n
with new lines"
但如果可能的话,我宁愿不要在任何地方添加引号。谢谢您的帮助!
编辑:我宁愿不使用空行。换句话说,我想使用 \n 来显示空行以使我的 yml 文件更具可读性。
我想这样做
test: >
This is a long string
\n\n\n
with new lines
但它会打印出“\n”而不是换行。
我知道这是可能的
test: "This is a long string
\n\n\n
with new lines"
但如果可能的话,我宁愿不要在任何地方添加引号。谢谢您的帮助!
编辑:我宁愿不使用空行。换句话说,我想使用 \n 来显示空行以使我的 yml 文件更具可读性。
尝试这个
test: |+
This is a long string
with new lines
| 后键有助于缩进多行文本的开头并保持长字符串的缩进。
你可以这样做 :
test: >+
This is a long string
with new lines
要在 yaml 中打印新行,您可以执行以下代码 我正在使用 degub 模块 msg func 像这样
debug:
msg:
- 'hello'
- 'name'