You can use os module to access environment variable values in Python as shown in the below example –
1 2 3 4 5 6 7 |
import os ## Print all environment variables along with values print(os.environ) ## Print a specific environment variable value print(os.environ['HOME']) |