我想將一個字符串作爲System Argument變量傳遞給python的gnuplot。我之前做了幾次,但令人驚訝的是這次並不奏效。我用這個主題How to pass command line argument to gnuplot?,但我沒有工作將字符串作爲系統參數變量傳遞給python的gnuplot
import subprocess
ii=2
while ii<5:
if (ii==2):
name='rectangular'
a="gnuplot -e 'name="+name+ "' graph3.gp"
if (ii==3):
name='trapezoidal'
if (ii==4):
name='simpson'
a="gnuplot -e 'name="+str(simpson)+ "' graph3.gp"
subprocess.call(a, shell='true')
ii=ii+1
我總是得到同樣的錯誤信息:
line 0: undefined variable: rectangular
line 0: undefined variable: trapezoidal
line 0: undefined variable: simpson
使用殼=真可以是一個安全[危險](https://docs.python.org/2/library/subprocess.html#常用參數) – Praveen
爲什麼?這怎麼會導致我的代碼中存在的問題?你會這樣做嗎? – anonymous