use python dotenv
pip install -U python-dotenv
#### And in your script
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
use python dotenv
pip install -U python-dotenv
#### And in your script
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
using dotenv_values
from dotenv import dotenv_values
# This function does not touch the os's environment rather it parses the .env file and returns a dict object
# containing parsed values
################################################################################################
# Example .env file
'''
# .env file
USER=foo
SECRET_KEY=v%)9n7kg^65(4-uir6!pa@oqqsdn8agv9h8_#ohn*55$th-gff
DOMAIN=tester.org
EMAIL=admin@${DOMAIN}
'''
################################################################################################
#Loading .env file values to config variable
config = dotenv_values(".env")
# above load is similar to executing the following in python
#config = {"USER":"foo","SECRET_KEY":"v%)9n7kg^65(4-uir6!pa@oqqsdn8agv9h8_#ohn*55$th-gff","EMAIL": "[email protected]"}
#therfore accessing values we query the keys
print(config.get("DOMAIN"))
#OUTPUT : [email protected]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us