python 获取环境变量
In Python, how to get an environment variable?
在Python中 ,如何获取环境变量?
In Python, you may use this piece of code to get an environment variable:
在Python中,您可以使用以下代码来获取环境变量:
os.environ.get('ENV_MIGHT_EXIST')
or this piece of code:
或这段代码:
os.getenv('ENV_MIGHT_EXIST')
It will return None
if the environment variable is not present.
如果环境变量不存在,它将返回None
。
Reference and for more ways, please check https://www.systutorials.com/dtivl/13/how-to-get-an-environment-variable?show=80#answer-80 .
参考以及更多方法,请检查https://www.systutorials.com/dtivl/13/how-to-get-an-environment-variable?show=80#answer-80 。
Answered by zma.
由zma回答。
翻译自: https://www.systutorials.com/how-to-get-an-environment-variable-in-python/
python 获取环境变量
最后
以上就是高大菠萝最近收集整理的关于python 获取环境变量_如何在Python中获取环境变量?的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复