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.
Asked
Active
Viewed 2,763 times
3
-
3Does 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 Answers
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