--- # 一个美味水果的列表 - Apple - Orange - Strawberry - Mango
键: 值
的形式组成(冒号后面必须有一个空格):--- # 一位职工的记录 name: Example Developer job: Developer skill: Elite # 另一种形式 {name: Example Developer, job: Developer, skill: Elite}
foo: "somebody said I should put a colon here: so I did"
GPUS: '0' DATA_DIR: '' OUTPUT_DIR: 'output' LOG_DIR: 'log' WORKERS: 8 PRINT_FREQ: 100 EXP_NAME: 'fully_supervised' CUDNN: BENCHMARK: True DETERMINISTIC: False ENABLED: True DATASET: DATASET: h36m ROOT: 'data/h36m/' TEST_SET: valid TRAIN_SET: train-fs FLIP: false TRI: false MPII_ORDER: false MODEL: NAME: pose3d_resnet PRETRAINED: '' RESUME: 'models/h36m/fully_supervised.pth.tar' NUM_JOINTS: 17 VOLUME: true EXTRA: FINAL_CONV_KERNEL: 1 DECONV_WITH_BIAS: false NUM_DECONV_LAYERS: 3 NUM_DECONV_FILTERS: - 256 - 256 - 256 NUM_DECONV_KERNELS: - 4 - 4 - 4 NUM_LAYERS: 50 TEST: BATCH_SIZE: 32 FLIP_TEST: false MODEL_FILE: '' DEBUG: DEBUG: false
https://www.cnblogs.com/klb561/p/9326677.html
name: Tom Smith age: 37 spouse: name: Jane Smith age: 25 children: - name: Jimmy Smith age: 15 - name1: Jenny Smith age1: 12
import yaml f = open(r'test_config.yml') y = yaml.load(f) print (y)
:YAMLLoadWarning: calling yaml.load() without Loader=… is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
y = yaml.load(f)
语法更新造成的,不影响使用。
解决办法: https://blog.csdn.net/rp517045939/article/details/88838417
改为y = yaml.load(list, Loader=yaml.FullLoader)
下面是一些其他模式
import yaml with open(r'test_config.yml') as f: y = yaml.load(f, Loader=yaml.FullLoader) print(y)