I am generating an YAML file by dumping a dictionary in Python using yaml.dump
function of the module 'pyyaml'. The following is my code where it dumps the dictionary to the YAML file.
with open('test.yaml', 'w') as outfile:
yaml.dump(yaml_dict, outfile, default_flow_style=False, sort_keys=False)
The script above creates an YAML file that represents the scalar values (e.g. '5') with single quotes like the following
data:
- name: Name
value: John
- name: Age
value: '5'
However, I want the YAML file to represent the scalar values in double quotes. Desired output:
data:
- name: Name
value: John
- name: Age
value: "5"
How can I pass the dictionary to the YAML file in a way that the scalar values are represented with double quotes?