Yaml 文件的操作

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']

  

posted @ 2020-05-07 17:35  siyu1216  阅读(280)  评论(0编辑  收藏  举报