我能够将数据打印到控制台上。但是,如果我要将其存储在日志文件中,该怎么办?
这是我的代码:
def pkt_callback(pkt):
pkt_raw = raw(pkt)
print(" packet received ", pkt_raw)
**logger.info("Packet Received: %s",pkt_raw)**
self.P = sniff(
count = self.c,
filter="dst host %s or src host %s and udp and dport %s" % (self.dst, self.src, self.Port),
prn = pkt_callback
)
我在粗体字部分出现错误:
ascii' codec can't decode byte 0xff in position 54: ordinal not in range(128)