python 以数组格式打印字符串
我将一个参数传递给像 -b bench
这样的 python 脚本。 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
但它没有' t 正确显示上述陈述。相反,它显示:
['~/myFD/src/bin/Assembler', '-s', '~/myFD/output/data.scratch', ' < ', '~/myFD/input/in.fa']
我该如何解决这个问题?
I passed an argument to a python script like -b bench
. The bench
is created like this:
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]
The bench.cmd
should looks like:
~/myFD/src/bin/Assembler -s ~/myFD/output/data.scratch < ~/myFD/input/in.fa
to do that, I use print bench.cmd
but it doesn't show the above statment correctly. Instead it shows:
['~/myFD/src/bin/Assembler', '-s', '~/myFD/output/data.scratch', ' < ', '~/myFD/input/in.fa']
how can I fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试:
print ' '.join(bench.cmd)
。这将连接列表并使用空格作为分隔符Try:
print ' '.join(bench.cmd)
. This joins the list and uses a space as delimiter您可以执行
' '.join(bench.cmd)
。You could do
' '.join(bench.cmd)
.连接的情况:
' '.join(bench.cmd)
case for join:
' '.join(bench.cmd)
您是在寻找这个,
还是只是连接字符串
Are you looking for this,
or just concatenate your strings