First of all, install the pyyaml
package using pip
in the command line.
pip install pyyaml
code.py
import yaml with open(r'file.yaml') as file: # The FullLoader parameter handles the conversion from YAML # scalar values to Python the dictionary format fruits_list = yaml.load(file, Loader=yaml.FullLoader) print(fruits_list)