How to list out all the environment variable in python?

Viewed 39

I want to list out all the environment variables in my system in python. The list should give me the name of the variable and its value.

1 Answers

Using os module of python it is possible to list out the environment variables.

import os

for name, value in os.environ.items():
    print("{0}: {1}".format(name, value))
Related