Monday, March 11, 2013

Python - List environment variables

Hey folks!

Here is a simple python script to list out environment variables. It can be used to figure out value of any environment variable and use that dynamically in your scripts.

import os
for key in os.environ:
    print key,'=>',os.getenv(key)

This is an example for Python 2.7. If  you are using Python v3.x, you will need to use print statement as a function.

No comments:

Post a Comment