Day 15 Task: Python Libraries for DevOps

Day 15 Task: Python Libraries for DevOps

Python day-to-day tasks

Tasks

  1. Create a Dictionary in Python and write it to a JSON File

    simply create a dictionary in Python and convert this Python object into JSON object and write into the JSON file.

    Json.dumps() - convert the python object into an equivalent JSON object and stores the result into a JSON file at the working directory.

  2. Read a JSON file services.json kept in this folder and print the service names of every cloud service provider.

    json.load() : A Python dictionary is created and it is returned via the json.load() function.

output

aws : ec2
azure : VM
gcp : compute engine

  1. Read YAML file using python, file services.yaml and read the contents to convert yaml to json

  1. Install PyYAML with pip install

  2. import yaml statement will import the module.

  3. the open method will view the file

  4. yaml.safe_load() - Prases the given and returns a python object constructed from the first document in the stream.

Thank you for reading this article!

Happy Learning!