How to serialize data to YAML format in Python?
How to serialize data to YAML format in Python?
How to serialize data to YAML format in Python?
solveurit24@gmail.com Changed status to publish February 13, 2025
Use the ruamel.yaml library to serialize data into YAML.
from ruamel.yaml import YAML
data = {'name': 'Alice', 'age': 30}
yaml = YAML()
with open('data.yaml', 'w') as f:
yaml.dump(data, f)solveurit24@gmail.com Changed status to publish February 13, 2025