pip install pyyaml
import yaml
# Writing YAML
data = {
'name': 'John Doe',
'job': 'Software Engineer',
'skills': ['Python', 'Java', 'C++']
}
with open('data.yaml', 'w') as file:
yaml.dump(data, file)
# Reading YAML
with open('data.yaml', 'r') as file:
data_loaded = yaml.safe_load(file)
print(data_loaded)