with open(filedonepath, 'wb') as fileSeg:
for i in range(len(fileTrainSeg)):
fileSeg.write(fileTrainSeg[i][0].encode('utf-8'))
fileSeg.write(('\r').encode('utf-8'))
分词的时候最后写入换行符,因为没有编码出现问题TypeError: a bytes-like object is required, not ‘str’,使用encode对字符进行编码后运行正常。