擅长:python、mysql、java
<p>每个子进程调用都有自己的shell,因此<code>cd</code>实际上不会影响后面的调用,因为您在错误的目录中,调用会中断。试试看</p>
<pre><code>os.chdir("G:\Programs\dsi_studio_64")
subprocess.call("dsi_studio action=trk source=HarveyReg2.hdr.src.gz.odf4.f5rec.012fx.rdi.gqi.0.2.fib.gz method=0 fa_threshold=0.00000 turning_angle=70 step_size=0.01 smoothing=0 min_length=0.0 max_length=300.0 initial_dir=0 seed_plan=0 interpolation=0 thread_count=12 seed=leftprechiasm.nii.gz roi=1.nii.gz fiber_count=100 output=track4.trk", shell=True)
</code></pre>
<p>也可以使用call()的<code>cwd</code>参数来完成,如</p>
<pre><code>subprocess.call("your long command", cwd="directory")
</code></pre>