How can you get an environment variable without raising KeyError if missing in Python?
Correct answer
A. os.environ.get('NAME')
5 views
A. os.environ.get('NAME')
5 views
dict-style get() returns None when the variable is missing; os.getenv works too.
Asked in: Python Interview Standard Library
https://docs.python.org/3/library/index.htmlNot sure why the answer is A? Ask here and get an explanation.