我收到了这个错误,我在 python 中很长时间无法弄清楚:
Traceback (most recent call last):
File "st2110_parse_KB.py", line 173, in <module>
section_header = get_pcapng_section_header(input_pcapng_file)
File "Z:\easy_parse\pcapng.py", line 190, in get_pcapng_section_header
assert(block_types[block_type] == "Section Header Block"), \
KeyError: 3569595041L
我正在调用get_pcapng_section_header()
我导入的另一个文件中的函数,如下所示:
from easy_parse.pcapng import *
这是我从主函数调用模块的方式:
# input_pcapng_file = open("filename.pcap",'rb')
if filename:
print "file works"
else:
print "doesnt"
port_filter_str + '.payload'
print "its fine here"
section_header = get_pcapng_section_header(input_pcapng_file)
这是 pcapng 模块的片段:
def get_pcapng_section_header(input_file):
# The Section Header Block is special because it defines the endian.
# Because of this get_pcapng_block (which requires endian) won't be used
# until the endian is determined.
section_header_block_file_position = input_file.tell()
# The endian doesn't matter for the Section Header Block's Block Type.
block_type = bytes_to_int(input_file.read(4), "big")
assert(block_types[block_type] == "Section Header Block"), \
"Block Type %d is not Section Header Block at 0x%08x" % (block_type, section_header_block_file_position)
# Skip the length for now.
input_file.read(4)