How can I set my DATABASE_URL as an environment variable in Python on Windows?
Asked
Active
Viewed 264 times
-2
-
1Do you have an example or a specific issue? You will be more likely to receive an answer if you post some code. Environment variables are available in the `os` module in `os.environ` – Iain Shelvington Jun 16 '20 at 04:23
1 Answers
0
With the os
module of the standard library;
>>> import os
>>> os.environ.get('NON_EXISTANT')
None
>>> os.environ.get('HOME')
/home/username
If you want to set such a variable;
>>> os.environ['YOUR_VARIABLE'] = 'your_value'
Note: print all available environment variables with os.environ
.

Sy Ker
- 2,047
- 1
- 4
- 20