Print environment variables in Python

In this article, we will see a how to print environment variables in Python.

We cab use environ attribute of os module for accessing environment variables using python program. This attribute gives environment dictionary which contains environment variables and its corresponding values.

Now, Let’s see given below Python code:


Now, let’s print only environment variables, so for this, we need only keys of environment dictionary.
Below is the Python code given:


That’s all about how to print environment variables in Python

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.