3

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.

Hasidul Islam
  • 324
  • 3
  • 12
  • 3
    Does this answer your question? [How do I access environment variables in Python?](https://stackoverflow.com/questions/4906977/how-do-i-access-environment-variables-in-python) – Mandera Sep 18 '22 at 10:57

1 Answers1

2

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))
Hasidul Islam
  • 324
  • 3
  • 12