开发者

yaml property value

开发者 https://www.devze.com 2023-01-10 06:23 出处:网络
I am using yaml file to store attribute and value. But some of the values need the current date to be appended.

I am using yaml file to store attribute and value. But some of the values need the current date to be appended.

So how do I enter the v开发者_运维技巧alue in yaml file, so that yaml parser can automatically recognise and substitute with current date

I am using pyyaml and python


pyyaml does not automatically substitute anything. Just use a custom string e.g. ${now} and replace it with the current date after parsing the yaml file.

For example,

value.replace("${now}", datetime.date.today().isoformat())

where value is a sting read from the input file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号