1

这确实是一个用python编写的简单脚本,我可以在Linux上正常运行它。但是当我将它移到 Windows 时,出现了一个奇怪的错误。我希望有所帮助。

在运行代码之前,我对环境做了一些准备:
1.安装Microsoft Visual C++ Compiler for python 2.7
2.安装python 2.7.11 3.pip
install pyinstaller
4.easy_install pyshark
下面是我的部分代码。

# -*- coding: utf-8 -*-
from __future__ import print_function
import pyshark
import lxml
import os

def analysis_method(file_name):
    cap = pyshark.FileCapture(input_file=file_name)
    for packet in cap:
        if hasattr(packet, "http"):
            http_layer = packet["http"]

以下是错误信息:
Traceback(最近一次调用最后一次):
文件“packet_offline_analysis.py”,第 36 行,在 analysis_method
中用于 cap 中的数据包:
文件“C:\Python27\lib\site-packages\pyshark-0.3.6.1- py2.7.egg\pyshark\capture\capture.py”,第 173 行,在 _packets_from_tshark_sync
self._get_packet_from_stream(tshark_process.stdout, data, psml_structure=psml_structure))
文件“C:\Python27\lib\site-packages\trollius- 1.0.4-py2.7-win32.egg\trollius\base_events.py”,第 300 行,在 run_until_complete
返回 future.result()
文件“C:\Python27\lib\site-packages\trollius-1.0.4-py2 .7-win32.egg\trollius\futures.py",第 287 行,结果
引发 self._exception
lxml.etree.XMLSyntaxError:输入不正确的UTF-8,表示编码!
字节:0xD6 0xD0 0xB9 0xFA,第 6 行,第 58 列

4

1 回答 1

0

卸载中文版的 Wireshark,然后安装英文版的 Wireshark。然后问题就解决了。

于 2016-09-27T11:00:50.223 回答