1.文件布局
打开文件修改读取方式为w
load函数加载文件
class ReadConfiYaml:
def __init__(self,yaml_file):
self.yaml_file=yaml_file
def read_yaml(self):
with open(self.yaml_file,encoding='utf-8') as f:
student=yaml.load(stream=f.read(),Loader=yaml.FullLoader)
print(student,type(student))
if __name__ == '__main__':
rc=ReadConfiYaml('config.yaml')
rc.read_yaml()
3.结果