【发布时间】:2017-12-14 00:43:43
【问题描述】:
我是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
【问题讨论】:
-
错误信息似乎很清楚。你的朋友可以读取文件是什么意思?