Python Projects & Skills / The web and automation
Lesson 19 of 28
Environment variables
Environment variables hold settings and secrets outside your code. os.environ reads them.
Key points
- os.environ.get('NAME')
- Use a .env file locally
- Never commit secrets to git
import os
api_key = os.environ.get("WEATHER_KEY")Quiz · +10 XP
Why store secrets in environment variables?
Log in to save progress and earn XP.