문제

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 value 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top