How to deserialize a YAML file in Python?

93 views

How to deserialize a YAML file in Python?

How to deserialize a YAML file in Python?

solveurit24@gmail.com Changed status to publish February 13, 2025
0

Use ruamel.yaml to load data from a YAML file.

from ruamel.yaml import YAML

yaml = YAML()
with open('data.yaml', 'r') as f:
    data = yaml.load(f)
print(data)  # Output: {'name': 'Alice', 'age': 30}

solveurit24@gmail.com Changed status to publish February 13, 2025
0