我正在使用 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
有人知道我的代码有什么问题吗?