Last active
September 20, 2024 21:54
-
-
Save konverner/3c39bba011bab3490d06acedfe20e336 to your computer and use it in GitHub Desktop.
Load environment variables from .env in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install python-dotenv | |
import os | |
from dotenv import find_dotenv, load_dotenv | |
# load variables from .env | |
load_dotenv(find_dotenv(usecwd=True)) | |
MY_VAR = os.getenv("MY_VAR") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment