Update 基础.md

This commit is contained in:
Zaixu Zheng 2024-05-02 22:05:16 +08:00 committed by GitHub
parent b4d4714d52
commit a88b210221
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,4 +2,66 @@
sidebar_position: 2
---
TODO
## 概要
- 大小写敏感
- 使用缩进表示层级关系
- 缩进不允许使用tab只允许空格
- 缩进的空格数不重要,只要相同层级的元素左对齐即可
- #’表示注释
## 数据类型
### 对象
键值对的集合。
形如 `key: value`,也可以形如 `key: {key1: value1, key2: value2, ...}`
### 数组
以‘-’开头的行表示构成一个数组,数组是一组按次序排列的值。
yaml支持多为数组可以使用行内表示`key: [value1, value2, ...]`
这个写法相当于:
```yaml
key:
- value1
- value2
- ...
```
### 复合结构
数组和对象可以构成复合结构,例:
```yaml
languages:
- Ruby
- Perl
- Python
websites:
YAML: yaml.org
Ruby: ruby-lang.org
Python: python.org
Perl: use.perl.org
```
转换为json为
```json
{
languages: [ 'Ruby', 'Perl', 'Python'],
websites: {
YAML: 'yaml.org',
Ruby: 'ruby-lang.org',
Python: 'python.org',
Perl: 'use.perl.org'
}
}
```
### 纯量
纯量是最基本的,不可再分的值,包括:
- 字符串
- 布尔值
- 整数
- 浮点数
- Null
- 时间
- 日期