Reading the .env environment file in Python
- .env file in the same folder where the program is.
examples/os/.env
SOME_THING=some value
examples/os/show_env.py
import os print(os.environ.get('MYNAME')) print(os.getenv('MYNAME'))
pip install python-dotenv
python examples/os/read_env.py SOME_THING=other python examples/os/read_env.py