这是代码:
def readFasta(filename):
""" Reads a sequence in Fasta format """
fp = open(filename, 'rb')
header = ""
seq = ""
while True:
line = fp.readline()
if (line == ""):
break
if (line.startswith('>')):
header = line[1:].strip()
else:
seq = fp.read().replace('\n','')
seq = seq.replace('\r','') # for windows
break
fp.close()
return (header, seq)
FASTAsequence = readFasta("MusChr01.fa")
我得到的错误是:
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
但是startswith
根据文档,第一个参数应该是一个字符串......那是怎么回事?
我假设我至少使用 Python 3,因为我使用的是最新版本的 LiClipse。