Hi 🙂🖐
In this post, I will share with you how o get env variables from .env
file using Python.
To load environment variables from .env
file you need to install
python-dotenv from here 🤗
https://pypi.org/project/python-dotenv/
Create .env
file and add variables
a = 123
x = 100
Now we have a .env
file we can load environment variables
using this code.
import dotenv
import os
dotenv.load_dotenv()
val = os.environ.get('x')
print(val)
result
123