[Work] Module small record - read .yaml file and generate a dictionary from the content

Read the .yaml file and generate a dictionary from the content

import yaml

config_file = '/home/TFace-master/TFace-master/recognition/train.yaml'
with open(config_file, 'r') as ifs:
    config = yaml.safe_load(ifs)
print(config)
print(config['INPUT_SIZE'])          # INPUT_SIZE: [112, 112]
print(config.get('DIST_FC', True))   # DIST_FC: true

The results show that:
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45392674/article/details/126171111