Skip to content

Instantly share code, notes, and snippets.

@konverner
Last active September 20, 2024 21:54
Show Gist options
  • Save konverner/3c39bba011bab3490d06acedfe20e336 to your computer and use it in GitHub Desktop.
Save konverner/3c39bba011bab3490d06acedfe20e336 to your computer and use it in GitHub Desktop.
Load environment variables from .env in Python
# 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