
Use it to convert the YAML file into a Python dictionary. Using the PyYAML module, we can perform various actions such as reading and writing complex configuration YAML files, serializing and persisting YMAL data. PyYAML is a YAML parser and emitter for Python.
Object Serialization: YAML data format is serializable. So we can write in one language and can be used in other languages without any modifications. Support in All Programming Languages: The YAML file is supported in all programming languages. Readable: The YAML file format doesn’t involve many rules, and only simple indentation is used to identify the individual blocks and documents. The YAML document ends with an optional … and we can have multiple documents inside a single YAML file. Indentation is used to indicate the nesting of items inside the TablesList.A hyphen precedes each subitem inside. The values can be of any type e.g., the phone number is numeric, and the userName is String. YAML documents start with a - (dash or hyphen) three times. In this tutorial, we use the following YAML file ( Userdetails.yaml) # YAML Document starts with. A key is generally string, and the value can be any scalars data type like String, Integer or list, array, etc. The YAML file is saved with extension yaml or yml.ĭata in YAML contains blocks with individual items stored as a key-value pair. Let us see one sample YAML file to understand the basic rules for creating a file in YAML.