dotenv
| Use Case | Command | Description |
|---|---|---|
| Load .env file | load_dotenv('.env') | Parse .env and set environment variables |
| Get values as dict | dotenv_values('.env') | Return content of .env as dict |
| Find .env file | find_dotenv() | Search for .env file upward from current directory |
| Set key/value | set_key('.env', 'KEY', 'value') | Add or update a key in .env file |
| Get single key | get_key('.env', 'KEY') | Read a specific key's value from .env |
| Unset key | unset_key('.env', 'KEY') | Remove a key from .env file |
| CLI shell string | get_cli_string(path, action, key, value) | Generate shell command string for fabric tasks |
__main__cliipythonmainparservariablesversiondotenv_values(dotenv_path: Union[str, ForwardRef('os.PathLike[str]'), NoneType] = None, stream: Optional[IO[str]] = None, verbose: bool = False, interpolate: bool = True, encoding: Optional[str] = 'utf-8') -> Dict[str, Optional[str]] — Parse a .env file and return its content as a dict.None values for keys without values in the .env file.foo=bar results in {"foo": "bar"} whereas foo alone results in {"foo": None}StringIO object with .env content, used if dotenv_path is None.dotenv_path and stream are None, find_dotenv() is used to find the .env file.find_dotenv(filename: str = '.env', raise_error_if_not_found: bool = False, usecwd: bool = False) -> str — Search in increasingly higher folders for the given fileget_cli_string(path: Optional[str] = None, action: Optional[str] = None, key: Optional[str] = None, value: Optional[str] = None, quote: Optional[str] = None) — Returns a string suitable for running as a shell script.local or run command.get_key(dotenv_path: Union[str, ForwardRef('os.PathLike[str]')], key_to_get: str, encoding: Optional[str] = 'utf-8') -> Optional[str] — Get the value of a given key from the given .env.None if the key isn't found or doesn't have a value.load_dotenv(dotenv_path: Union[str, ForwardRef('os.PathLike[str]'), NoneType] = None, stream: Optional[IO[str]] = None, verbose: bool = False, override: bool = False, interpolate: bool = True, encoding: Optional[str] = 'utf-8') -> bool — Parse a .env file and then load all the variables found as environment variables.io.StringIO) with .env content, used if dotenv_path is None..env file.dotenv_path and stream are None, find_dotenv() is used to find the .env file with its default parameters. If you need to change the default parameters of find_dotenv(), you can explicitly call find_dotenv() and pass the result to this function as dotenv_path.PYTHON_DOTENV_DISABLED is set to a truthy value, .env loading is disabled.load_ipython_extension(ipython: Any) -> Noneset_key(dotenv_path: Union[str, ForwardRef('os.PathLike[str]')], key_to_set: str, value_to_set: str, quote_mode: str = 'always', export: bool = False, encoding: Optional[str] = 'utf-8', follow_symlinks: bool = False) -> Tuple[Optional[bool], str, str] — Adds or Updates a key/value to the given .envfollow_symlinks.unset_key(dotenv_path: Union[str, ForwardRef('os.PathLike[str]')], key_to_unset: str, quote_mode: str = 'always', encoding: Optional[str] = 'utf-8', follow_symlinks: bool = False) -> Tuple[Optional[bool], str] — Removes a given key from the given .env file.follow_symlinks.__all__ = ['get_cli_string', 'load_dotenv', 'dotenv_values', 'get_key', ...]
/home/chedong/.local/lib/python3.10/site-packages/dotenv/__init__.py
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 15:00 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format