1、创建yaml 文件,添加内容
book_002: {"author": "wuya","done": true,"name": "API实战测试"}
2、创建文件,读取yaml 文件中的内容
import yaml def readYaml(): with open('book.yaml'),'r',encoding='utf-8') as f: return yaml.safe_load(f) readYaml()['book_002']