我给一个python脚本传递了一个参数,比如-b bench
。bench
的创建方式如下:
bench_dir = '~/myFD/'
bench_bin = bench_dir + 'src/bin/Assembler'
bench_inp1 = bench_dir + 'input/in.fa'
bench_out1 = bench_dir + 'output/data.scratch'
bench= LiveProcess()
bench.executable = bench_bin
bench.cwd = bench_dir
bench.cmd = [bench.executable] + ['-s', bench_out1, '<', bench_inp1]
bench.cmd
应该是:~/myFD/src/bin/Assembler -s ~/myFD/output/data.scratch < ~/myFD/input/in.fa
为此,我使用
print bench.cmd
但它没有正确显示上述语句。相反,它显示:['~/myFD/src/bin/Assembler', '-s', '~/myFD/output/data.scratch', ' < ', '~/myFD/input/in.fa']
我该怎么解决?
最佳答案
尝试:print ' '.join(bench.cmd)
。这将连接列表并使用空格作为分隔符