Created
December 11, 2017 09:18
-
-
Save akkefa/46ba3528eaa9d5e1b09496bcdd996545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
print os.environ['HOME'] | |
# Or you can see a list of all the environment variables using: | |
os.environ | |
#As sometimes you might need to see a complete list! | |
# using get will return `None` if a key is not present rather than raise a `KeyError` | |
print os.environ.get('KEY_THAT_MIGHT_EXIST') | |
# os.getenv is equivalent, and can also give a default value instead of `None` | |
print os.getenv('KEY_THAT_MIGHT_EXIST', default_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment