yaml pip install PyYAML import yamlyaml_file = "test.yaml" data = yaml.load(open(yaml_file), Loader=yaml.FullLoader) print(data) test.yaml 文件内容 age: 10 name: J name2: "J" worker: True : 后跟空格; 字符串加不加引号都可; 布尔类型,True,False;