Python Module os
Jump to navigation
Jump to search
External
Internal
Overview
Environment Variables
To get an environment variable:
import os
print(os.environ.get('HOME'))
If the environment variable does not exist, the call will get None
To set an environment variable:
import os
os.environ['MY_VAR'] = 'myvalue'
This works for testing.