python save i yml file code example
Example 1: python write yaml
import yaml
dict_file = [{'sports' : ['soccer', 'football', 'basketball', 'cricket', 'hockey', 'table tennis']},
{'countries' : ['Pakistan', 'USA', 'India', 'China', 'Germany', 'France', 'Spain']}]
with open(r'E:\data\store_file.yaml', 'w') as file:
documents = yaml.dump(dict_file, file)
Example 2: read yml file in python
{'a_key': 'a_value', 'another_key': 'another_value', 'nested_dictionary': {'nested_key': 'nested_value'}}