I know the module os
and how to use like os.environ.get('a', 'b')
. It will catch current environment variable 'a', if not exists will default to 'b'.
But today I have a small problem. This is my tiny project about the problem:
.vscode/
launch.json
.env
runme.py
For runme.py:
import os
vv = os.environ.get('SETTINGS', 'Nothing')
print(vv)
And also the .env file is quite simple like runme.py
SETTINGS = proj.settings.local
In launch.json, follow Python debugging configurations in VS Code
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/runme.py"
}
]
}
After that, press F5, I see what I expect to see in INTERNAL TERMINAL
>cd d:\tmp\tt && cmd /C "set "SETTINGS=proj.settings.local" && set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && python c:\Users\tony\.vscode\extensions\ms-python.python-2018.7.1\pythonFiles\PythonTools\visualstudio_py_launcher.py d:\tmp\tt 62502 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput D:\tmp\tt/runme.py "
proj.settings.local
But when I just run the command in COMMAND LINE python runme.py
, I saw 'Nothing' printed in COMMAND LINE. WHY?
Is that IDE(ex: VSCode) do for me? Or something I misunderstand about the os module
? Please explain it to me.