Sometimes, we want to set environment variables in Python.
In this article, we’ll look at how to set environment variables in Python.
How to set environment variables in Python?
To set environment variables in Python, we can put the variable os.environ
dict.
For instance, we write
os.environ["FOO"] = "1"
to set the FOO environment variable to '1
‘.
We can get the environment variable’s value with
print(os.environ["DEBUSSY"])
Conclusion
To set environment variables in Python, we can put the variable os.environ
dict.