05 k8s考试基础知识(四)
但是缩进消失了>-
·
yaml 编写知识
01 大小写敏感
One: 1
one: 2
{One: 1, one: 2}
02 起始位置
--- : 表示起始位置
... : 表示结束位置
03 map 中的字符串
| 每个有文本的行都保留换行符
|- 除去最后一个有文本的行,每个有文本的行都保留换行符
|+ 有行就有换行符号
bird: Toucans
{
"bird": "Toucans"
}
bird: "Birds Lover do you know? Learn how to describe birds."
{
"bird": "Birds Lover do you know? Learn how to describe birds."
}
|保留换行符,每一行都有换行符,有内容才有换行符,空行不显示换行符号
bird: |
Birds Lover do you know?
Learn how to describe birds.
{
"bird": "Birds Lover do you know?\nLearn how to describe birds.\n"
}
|+ 保留换行符,每一行都有换行符,空行也有换行符 (有网友称之为尾随空格
bird: |+
Birds Lover do you know?
Learn how to describe birds.
{
"bird": "Birds Lover do you know?\nLearn how to describe birds.\n\n\n\n\n\n\n\n\n\n\n"
}
|- 保留换行符,尾行没有换行符号,之后空行也不会有换行符号
bird: |-
Birds Lover do you know?
Learn how to describe birds.
{
"bird": "Birds Lover do you know?\nLearn how to describe birds."
}
以上的三个仅仅是对于换行符号有差别,空格符号没有差别
bird: |-
Birds Lover do you know?
Learn how to describe birds.
Toucans
Stork
对于这些多行文本,是保留其具有的缩进的
折叠多行字符串
> 有文本的行,会转换成行,并且保留最后一个文本行的换行符,但是缩进消失了
>- 有文本的行,会转换成行,并且保留最后一个文本行的换行符,保留缩进
有时候你想在你的YAML中用多行代表一个字符串,但是当它被解释时,要把它当作一个长行。这被称为“折叠”。要声明一个折叠块,使用>
代替|
:
bird: >
Birds Lover do you know?
Learn how to describe birds.
{
"bird": "Birds Lover do you know? Learn how to describe birds.\n"
}
bird: >-
Birds Lover do you know?
Learn how to describe birds.
{
"bird": "Birds Lover do you know?\n Learn how to describe birds."
}
更多推荐
已为社区贡献4条内容
所有评论(0)