With the os module of the standard library;
>>> import os
>>> os.environ.get('NON_EXISTANT')
None
>>> os.environ.get('HOME')
/home/username
If you want to set such a variable;
>>> os.environ['YOUR_VARIABLE'] = 'your_value'
Note: print all available environment variables with os.environ.
osmodule inos.environ