在我的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