我試圖使用環境變量將一些祕密傳遞給shell命令。 Popen似乎使用「單引號概念」來逃避參數,所以命令無法獲取變量值。如何獲得Popen中的shell變量值
Python 2.7.1 (r271:86832, Mar 3 2017, 10:25:58)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.Popen(['echo','$PATH'])
$PATH
預期輸出是真正的$ PATH值分別爲 「/ bin中:/ sbin目錄:在/ usr/bin中......」
謝謝!