考虑一个变量“outdir”,包含在命令行中创建一个我将存放输出的目录,调用只接受“-o = both”等参数的子进程的最佳选择是什么允许参数(-d =)和值(outdir)之间的空格?
之前可以建立 '-o=both','-m=both' and '-t=4'
,我已将其包含在我的脚本中。
这是我使用的行:
subprocess.call(['external_script.pl', '-d=',outdir,'-o=both','-m=both','-t=4'])
答案 0 :(得分:1)
为什么不直接根据需要设置参数:
['external_script.pl',' - d =%s'%outdir,' - o = both',' - m = both',' - t = 4']
答案 1 :(得分:0)
我在行中更改了','为'+'并且它有效。
subprocess.call(['external_script.pl', '-d='+outdir,'-o=both','-m=both','-t=4'])