yaml中的三种数据类型
- map类型
name: vaadhoo
age: 24
- list类型
- python
- javascript
- perl
- scalar纯量
# 数值
price: 12.34
# 布尔值
enable: true
# 字符串
content: "this is the content"
# null值
append: ~
map和list的几种组合嵌套
- map-map嵌套
website:
yaml: yaml.org
python: python.org
perl: use.perl.org
- map-list嵌套
website:
- yaml
- python
- perl
- javascript
- list-list嵌套
-
- item11
- item12
-
- item21
- item22
- list-map嵌套
-
name: vaadhoo
age: 19
-
name: steven
age: 24
字符串
字符串默认不使用引号,如果包含空格或者特殊字符需要放在引号中
str: 'this is a string.'
引号分为单双引号,单引号时候会将特殊字符进行转义,双引号则默认不转义
s1: 'content\nsome content'
s2: "content\nsome content"
多行字符串,换行开始必须有一个单空格缩进,换行符会被转为空格
str:
this is a
multi-line
string
字符串配合|符号的一些操作
s1: |
Foo
Bar
s2: |+
Foo
s3: |-
Foo
s4: >
Foo
Bar