Python Environment Variables

Environment Variables

Show all environment variables

> set 
$ env

Set new value in environment variables

set SECRET_KEY=hello
$ export SECRET_KEY=helloenv

Python OS module

import osprint(os.environ)
os.environ['SECRET_KEY'] = "hello"
print(os.getenv('SECRET_KEY'))

dotenv python module

pip install python-dotenv
SECRET_KEY=thisissecretkey
import os
from dotenv import load_dotenv
load_dotenv()

print(os.getenv('SECRET_KEY'))

--

--

Learning javascript and web-development

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store