我想将一个字符串作为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