python读取yaml配置文件 python read yaml config file
import os
import yaml
home_dir = os.path.expanduser('~')
config_file = os.path.join(home_dir, '.trustlook', 'key.yaml')
try:
with open(config_file, 'r') as f:
config = yaml.safe_load(f)
except:
print 'Failed to read config file [{}]'.format(config_file)
sys.exit(1)