Python Libraries for DevOps

Python libraries are pre-written code collections that extend the functionality of the Python programming language. They provide modules, tools, and functions for specific tasks, making it easier for developers to build complex applications without starting from scratch. Some Python day-to-day tasks are:

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 in the working directory.

  1. 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 blog...!

Happy Learning! :)

0
Subscribe to my newsletter

Read articles from RAKESH REVASHETTI directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

RAKESH REVASHETTI
RAKESH REVASHETTI

I'm Rakesh, a DevOps engineer who enjoys automation, continuous integration and deployment. With good hands-on experience in DevOps & cloud technology, i'm proficient in various tools and technologies related to infrastructure automation, containerization, cloud platform, monitoring and CI/CD.