我给一个python脚本传递了一个参数,比如-b benchbench的创建方式如下:

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)。这将连接列表并使用空格作为分隔符

10-01 09:28