I am using yaml module to generate yaml file, But actually I am not getting proper expected output and below is the code:
import yaml
list1 = [{'Test01': '01', 'Test02': '02'}, {'Test03': '03', 'Test04': '04'}]
some_data = {"data": list1}
yaml_data = {
'version': '1.0'
}
yaml_data.update(some_data)
print(yaml.dump(yaml_data, default_flow_style=False))
Actual Output:
data:
- Test01: '01'
Test02: '02'
- Test03: '03'
Test04: '04'
version: '1.0'
Expected output:
data:
-
Test01: '01'
Test02: '02'
-
Test03: '03'
Test04: '04'
version: '1.0'