def writeabnormaldata(self,data_excel, dirname): mid_pcap = [] label_data = [] label_label = [] n = 1 # self.setDir(dirname) for i in range(len(data_excel)): if data_excel["data"][i] == 0: continue count = 0 mid_pcap.append(data_excel["data"][i]) data_number = bytes(str(data_excel["data"][i][2:-1]), encoding="utf-8") original = codecs.escape_decode(data_number, "hex-escape") path = "./" + dirname + "/第%d条数据流" % n + ".txt" with open(path, 'a') as f: label_data.append(original[0]) f.write(self.hexdump(original[0])) f.write("结束") label_label.append(n) count += 1 data_excel["data"][i] = 0 for j in range(i + 1, len(data_excel)): if data_excel["srcip"][i] == data_excel["srcip"][j] and data_excel["dstip"][i] == data_excel["dstip"][ j] and data_excel["sport"][i] == data_excel["sport"][j] and data_excel["dport"][i] == \ data_excel["dport"][j] and data_excel["proto"][i] == data_excel["proto"][j]: count += 1 if count>6 and count<=7: n += 1 count=0 mid_pcap.append(data_excel["data"][j]) data_number = bytes(data_excel["data"][j][2:-1], encoding="utf-8") original = codecs.escape_decode(data_number, "hex-escape") path = "./" + dirname + "/第%d条数据流" % n + ".txt" with open(path, 'a') as f: label_data.append(original[0]) f.write(self.hexdump(original[0])) f.write("结束") label_label.append(n) data_excel["data"][j] = 0 if count>0: n += 1 return label_data ,label_label整个代码的作用,详述
时间: 2023-06-03 12:04:39 浏览: 102
node全局变量__dirname与__filename的区别
这是一段 Python 代码,定义了一个名为 writeabnormaldata 的函数。该函数有三个输入参数:data_excel、dirname 和 self。函数中定义了三个变量:mid_pcap、label_data 和 label_label,以及一个计数变量 n。
阅读全文