For example
My yaml file(Test.yml):
JavaScript
x
3
1
fruit : &apple Apple
2
fruits : *apple , Pineapple
3
Python code
JavaScript
1
7
1
import yaml
2
3
with open('Test.yml', 'r') as f:
4
data = yaml.safe_load(f)
5
6
print(data['fruits'])
7
Output get error
JavaScript
1
3
1
yaml.parser.ParserError: while parsing a block mapping
2
expected <block end>, but found ','
3
My expected output is
JavaScript
1
2
1
Apple, Pineapple
2
Advertisement
Answer
You can make your fruits
be a sequence:
JavaScript
1
3
1
fruit: &apple Apple
2
fruits: [*apple, pineapple]
3
However you can not concatenate the scalar value Apple
to other values, because YAML is a pure data serialization language and cannot process data in any way.