在我的shell脚本的一个我使用eval命令象下面这样来评价环境路径 -如何在python环境路径中复制eval命令?
CONFIGFILE='config.txt'
###Read File Contents to Variables
while IFS=\| read TEMP_DIR_NAME EXT
do
eval DIR_NAME=$TEMP_DIR_NAME
echo $DIR_NAME
done < "$CONFIGFILE"
输出: - 什么是my_path的
$MY_PATH/folder1|.txt
$MY_PATH/folder2/another|.jpg
/path/to/certain/location/folder1
/path/to/certain/location/folder2/another
在config.txt
?
export | grep MY_PATH
declare -x MY_PATH="/path/to/certain/location"
那么,有没有办法,我可以从Python代码的路径一样,我可以在外壳与获得eval
想要在运行程序之前在python程序或环境中设置MY_PATH吗? – tdelaney