此代码返回以下错误消息:类型错误:强迫为Unicode:需要字符串或缓冲区
张开(infile中,模式= 'R',缓冲= -1)作为IN_F,开放(OUTFILE ,模式= 'W',缓冲= -1)为out_f: 类型错误:强迫为Unicode:需要字符串或缓冲区,文件中发现
# Opens each file to read/modify infile=open('110331_HS1A_1_rtTA.result','r') outfile=open('2.txt','w') import re with open (infile, mode='r', buffering=-1) as in_f, open (outfile, mode='w', buffering=-1) as out_f: f = (i for i in in_f if i.rstrip()) for line in f: _, k = line.split('\t',1) x = re.findall(r'^1..100\t([+-])chr(\d+):(\d+)\.\.(\d+).+$',k) if not x: continue out_f.write(' '.join(x[0]) + '\n')
请帮助我的人。
这么吓人真棒。谢谢! – 2013-11-07 16:13:04