用python3:
Traceback (most recent call last): File "genetic_disease_filtrater.py", line 139, in intron = txt2.readlines()
? File "/usr/local/lib/python3.6/codecs.py", line 321, in decode
? ? (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
找了半天原因,發(fā)現(xiàn)是被打開文件之前寫出時:encoding = "utf-16"
解決辦法:
打開文件時修改一下默認值:
with open(args.whanno_txt,"r",encoding='utf-16')
解決了
總結:
de這個bug跨時2天~? 之前也在打開時“r”改為“rb”,后面一系列有字符串的地方都要在前面加b,非常麻煩。所以先檢查一下被打開的文件是不是有什么問題,可能寫出這個文件的時候就不是默認的'utf-8'。