0
我想創建一個列表,其中每個元素都將成爲聯機文件的一行。但是當我想分割我的列表時,我收到EM:「TypeError:需要類似字節的對象,而不是'str'」。我已經嘗試解決這個問題('utf8'),但我不能。任何建議?拆分一個列表:類型錯誤:需要類似字節的對象,而不是'str'
def collect_record(name):
file = "http://www.uniprot.org/uniprot/%s.txt" %name
u=urllib.request.urlopen(file)
pdblines=u.readlines()
for line in pdblines :
line = ligne.strip()
pdblines = line.split("b")
u.close()
return pdblines
你需要完整回溯添加到您的帖子。此外,您的代碼中存在拼寫錯誤。 'ligne.strip()'。請提供[mcve]。 –