python读取yml文件

class Read_data_class:
    def read_yml_def(self, dir_path):
        with open(dir_path, 'r', encoding='utf-8') as f:
          yaml_list = yaml.safe_load(f)

          return yaml_list

if __name__ == '__main__':
     pass


class main():
  path = os.path.join(os.path.dirname(__file__), '文件.yml')
  data_yml = read_yml_data.Read_data_class().read_yml_def(path)
posted @ 2023-09-11 16:49  IT界的一名小婊渣  阅读(33)  评论(0编辑  收藏  举报