I am finding that the following code prints out my expected environmental variable when I execute the script in a shell:
import os
print(os.environ['STUFF'])
However, when I run this same code in Jupyter Notebook, I get a key error. I have tried restarting the Jupyter server. What else should I do?
答案 0 :(得分:0)
You can query all the dictionary keys to confirm the one you have is not there.
import os
print(os.environ.keys())
Or better you can test for the presence of the specific key.
print(os.environ.has_key('STUFF'))