我需要知道如何将一行代码中的单链DNA格式化为给定的宽度,这样它就可以读取多行。我要做的是在给定的宽度插入一个换行符。这是我迄今为止的代码:
def formatSeq(dna, width): #dna strand and given width passed to fucntion
seq =[]
start =0
while start < len(dna):
if start + width < len(dna):
seq = seq + dna[start:start+width]]
start = start + width
else:
seq += dna[start:]
seq.append('\n')
return seq
执行时,程序不终止,输出文件为空。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐