Environmental variables can be found in os.environ.
import os
print os.environ['HOME']
# If there is no key, return None, not KeyError
print os.environ.get('KEY_THAT_MIGHT_EXIST')
# Features such as get. Instead, you can specify default_value instead
print os.getenv('KEY_THAT_MIGHT_EXIST', default_value)
© 2024 OneMinuteCode. All rights reserved.