【发布时间】:2021-11-30 03:24:48
【问题描述】:
我有以下yaml文件config.yml:
PATH1: /this/is/the/first/path
PATH2: $PATH1/plus/second/path
我是这样用python读的:
import yaml
with open("../etc/test.yml", "r") as f:
config = yaml.safe_load(f)
print(config)
这显然是我打印配置字典时得到的:
{'PATH2': '$PATH1/plus/second/path', 'PATH1': '/this/is/the/first/path'}
我想要的是:
{'PATH2': '/this/is/the/first/path/plus/second/path', 'PATH1': '/this/is/the/first/path'}
是否有任何内置方法可以实现此目标? 还是我必须自己创造一些东西来替换它们?
【问题讨论】: