name: zs
- - zs
- - 18
- - 男
- - - name
- - zs
- - - age
- - 18
- - name:zs
- - age:18
- student1:
- name: zs
- age: 18
- student2:
- name: ls
- age: 20
- name:
- - zs
- - ls
- - ww
- age:
- - 18
- - 20
- - 30
- - name:
- - zs
- - age:
- - 18
- students:
- student1:
- name: zs
- age: 18
- student2:
- name: ls
- age: 20
- - students
- - student1
- - zs
- - 18
- - student2
- - ls
- - 20
- "整数": 1
- "浮点数": 1.3
- "字符串1": "hello"
- "字符串2": 'hello'
- "字符串3": hello123
- "布尔1": TRUE
- "布尔2": True
- "布尔3": true
- "空1": NULL
- "空2": null
- "空3": Null
- "时间": 2023-9-18 15:50:20
- with open("./data.yaml", "r", encoding="utf-8") as f:
- data = yaml.load(f, Loader=yaml.FullLoader)
- with open("./write_data.yaml", "w", encoding="utf-8") as f:
- data = {"name": "张三", "age": 18}
- yaml.dump(data, f, allow_unicode=True)