上面说的yaml文件再复杂些
时间: 2023-08-03 19:07:28 浏览: 41
好的,我理解为您想了解如何编写更加复杂的 YAML 文件,以下是一些示例:
1. 嵌套列表和字典:
```
- name: John
age: 30
hobbies:
- Sports
- Music
education:
degree: Master
school: XYZ University
- name: Jane
age: 25
hobbies:
- Reading
- Traveling
education:
degree: Bachelor
school: ABC College
```
2. 使用引用和锚点:
```
defaults: &defaults
timeout: 30
retries: 3
server1:
<<: *defaults
ip: 192.168.0.1
server2:
<<: *defaults
ip: 192.168.0.2
```
3. 使用双引号和单引号来表示字符串:
```
name: "John Doe"
address: '123 Main St'
```
4. 定义复杂的数据结构:
```
employees:
- name: John
age: 30
department:
name: Sales
location: New York
- name: Jane
age: 25
department:
name: Marketing
location: San Francisco
```
希望以上示例能对您有所帮助。