Day 15 Task: Python Libraries for DevOps

Day 15 Task: Python Libraries for DevOps

·

1 min read

Reading JSON and YAML in Python

Python has numerous libraries like os, sys, json, yaml etc that a DevOps Engineer uses in day to day tasks.

What is json file?

JSON (JavaScript Object Notation) file is a text file that contains data in a structured format using key-value pairs. It is commonly used for data exchange between a server and a web application, as well as for configuration files and data storage. JSON is language-independent and can be easily parsed and generated by various programming languages, including Python.

Tasks

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

(writing json file)

Here I have created a dictionary in python .

After creating the dictionary we will write the file i.e(f.write)it is shown in the image ,to write the json file we have to create a file in this scenario the file name is data.txt.

In the above image the the data.txt file will be created in your folder

In data.txt file we will have the content the is created in dictionary

reading json file

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