gpt4 book ai didi

python - Pyshark FileCapture 不起作用

转载 作者:行者123 更新时间:2023-12-05 07:38:32 26 4
gpt4 key购买 nike

我是pyshark的新手,我在教程上搜索写了一个示例代码

import pyshark
cap = pyshark.FileCapture("input.cap")
cap_1 = cap[0]

然后它给我一个错误

/Users/tingyugu/anaconda3/bin/python /Users/tingyugu/PycharmProjects/final/test.py
Traceback (most recent call last):
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 70, in __getitem__
next(self)
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 60, in __next__
packet = self._packet_generator.send(None)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/tingyugu/PycharmProjects/final/test.py", line 5, in <module>
cap_1 = cap[0]
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 73, in __getitem__
raise KeyError('Packet of index %d does not exist in capture' % packet_index)
KeyError: 'Packet of index 0 does not exist in capture'

我知道是cap里面没有包的原因,但是我的 friend 可以通过pyshark读取文件

我用的是python 3.6.0 anaconda,anaconda中pyshark是0.3.7

最佳答案

如果您使用的是 jupyter,请参阅 this issue在 PyShark Repo 上。我遇到了同样的问题,似乎 pyshark 与 jupyter 不兼容。我假设它也可能与 ipython 有同样的问题。有一些拉取请求,例如 this one在他们的 repo 上也作为修复,但还没有合并。

关于python - Pyshark FileCapture 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47804291/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com