简体   繁体   English

通过python从.bash_profile中读取

[英]read from .bash_profile via python

is there any way to read the .bash_profile using python? 有什么办法可以使用python读取.bash_profile? I need to get value of one of variables, like: 我需要获取变量之一的值,例如:

export JAVA_HOME=/usr/java

If you are looking for the value of a particular environment variable, there is no need to parse .bash_profile. 如果要查找特定环境变量的值,则无需解析.bash_profile。 Just check in os.environ . 只需签入os.environ

import os
os.environ['JAVA_HOME']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM