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
1pip install pyyaml
2
3import yaml
4with open("example.yaml", 'r') as stream:
5 try:
6 print(yaml.safe_load(stream))
7 except yaml.YAMLError as exc:
8 print(exc)
9