我是 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里没有包,但是我的朋友可以通过pyshark读取文件
我使用 python 3.6.0 anaconda 而 pyshark 在 anaconda 中是 0.3.7