在解码pcap文件并读取时,这部分出现了错误,如果不加utf-8会报gbk错误,加了以后
File "E:\PYTHON\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 0: invalid continuation byte
请求帮助我解决这个问题
def decodeTxt(filePath):
times = []
length = []
packetNum = 0
with open(filePath, "r",encoding="utf-8") as file:
for dada in file:
dada = dada.split(" ")
times.append(float(dada[0]))
length.append(int(dada[1]))
packetNum += 1
return times, length