我已经在python脚本中插入了一些shell命令,如下所示:
#!/usr/bin/python
import os,sys,re
import gzip
import commands
path = "/home/x/nearline"
for file in os.listdir(path):
if re.match('.*\.recal.fastq.gz', file):
fullpath = os.path.join(path, file)
result = commands.getoutput('zcat fullpath |wc -l')
numseqs = int(result)/4.0
print numseqs
Run Code Online (Sandbox Code Playgroud)
zcat fullpath |wc -l 是插入的shell命令.
问题是,我fullpath在这里为所有fastq文件定义,但在被放入之后' ',似乎这fullpath不起作用.我怎么解决这个问题?
您必须将字符串与变量的值连接:
result = commands.getoutput('zcat ' + fullpath + ' |wc -l')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1249 次 |
| 最近记录: |