1.创建yaml文件,输入要存储的参数,注意每个value值前面要加一个空格
2.使用open方法读取出来,获取文件流,第一个参数为文件的路径
f = open(file_path, 'r', encoding='utf-8').read()
3.然后转化为字典格式
f1=yaml.safe_load(f))
4.最终获取到的结果为json字符串
{'mp_login001': {'username': 'test01', 'code': 246810, 'expect': 123},
'mp_login002': {'username': 'test02', 'code': 123456, 'expect': 456}
}
5.使用f1.values()方法得到数组
[{'username': 'test01', 'code': 246810, 'expect': 123},
{'username': 'test02', 'code': 123456, 'expect': 456}
]