1# read_categories.py file
2
3import yaml
4
5with open(r'E:\data\categories.yaml') as file:
6 documents = yaml.full_load(file)
7
8 for item, doc in documents.items():
9 print(item, ":", doc)
10
1import yaml
2
3dict_file = [{'sports' : ['soccer', 'football', 'basketball', 'cricket', 'hockey', 'table tennis']},
4{'countries' : ['Pakistan', 'USA', 'India', 'China', 'Germany', 'France', 'Spain']}]
5
6with open(r'E:\data\store_file.yaml', 'w') as file:
7 documents = yaml.dump(dict_file, file)
8