将 shell 脚本转换为 python 并尝试找到执行以下操作的最佳方法。我需要它,因为它包含我需要阅读的环境变量。
if [ -e "/etc/rc.platform" ];
then
. "/etc/rc.platform"
fi
我已经转换了“if”,但不确定如何处理 . "/etc/rc.platform" 作为源是一个 shell 命令。到目前为止,我有以下
if os.path.isfile("/etc/rc.platform"):
print "exists" <just to verify the if if working>
<what goes here to replace "source /etc/rc.platform"?>
我查看了 subprocess 和 execfile 没有成功。
python 脚本需要访问 rc.platform 设置的环境变量