我使用Python和這裏有一塊我的代碼:錯誤:必須海峽,沒有在Python
wp = open(outfile, 'w')
fields = line.split('\t')
gene_ID = fields[0]
chr = fields[1]
strand = fields[2]
start = int(fields[3])
end = int(fields[4])
bc = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A', 'N':'N'}
if strand == '+':
wp.write(chr_string[start:end])
if strand == '-':
newstart, newend = -(start + 1), -(end + 1)
wp.write(bc[base.upper()] for base in chr_string[newstart:newend]) <--error pointed at this line
當我嘗試運行我的整個代碼,我得到以下信息:
TypeError: must be str, not generator
有沒有人知道我的代碼是什麼毛病提示呢?
嗯,這是相當不言自明的:你正在傳遞一個生成器表達式到'write',當它期待一個字符串時... – Cameron 2012-04-27 17:38:33