I'm a beginner in python and trying to pull data from yaml file to use in a python script, say my yaml file looks like this:
---
genre: horror
film:
-name: conjuring
-id: 1234
film:
-name: halloween
-id: 1222
How would I select each part of the yaml, for example say I want the id of the film with the name halloween using python? I managed to read the file in by writing this:
import yaml
with open("films.yaml", 'r') as stream:
try:
code = yaml.load(stream)
print(code.each)
except yaml.YAMLError as exc:
print(exc)
but that only gives me the following output and doesn't display everything:
{'genre': 'horror', 'film': {'-name': 'halloween', '-id': 1222}}
Any help is appreciated.