yaml文件
student:
name: 王
age: 18
subject:
- yuwen
- english
- shuxue
class: ['一班','二班','三班']
system:
- name: dos
port: 8080
env: dev
- name: linux
port: 8080
env: test
读取文件
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2022/11/19 15:43
# @Author :
# @File : yml_test.py
# pip install PyYAML
import yaml
with open('test.yml', encoding='utf-8') as f:
dict_data = yaml.safe_load(f)
print(dict_data)
print(type(dict_data))