python-2.7 - Python提取味精库:'gbk'编解码器无法解码字节:非法多字节序列
问题描述
错误详情
- 使用最新支持的 extract_msg 版本。(extract_msg-0.23.2-py2.py3-none-any.whl)
- 蟒蛇版本:Python 2.7 / Python 3.8
描述 我有一个提取电子邮件文件的应用程序。如果邮件文件包含 gbk 编解码器(中文字符),模块方法 Message(path to file) 会抛出异常。
代码片段
from extract_msg import Message
try:
msg = Message(vault_path)
except Exception as e:
return action_result.set_status(APP_ERROR, "Failed to parse message. Error: {0}".format(str(e)))
来自库调用的错误消息
“消息”:“无法解析消息。错误:'gbk'编解码器无法解码位置 34-35 中的字节:非法多字节序列”
追溯:
File "/opt/folder/dependencies/extract_msg/message.py", line 95, in __init__#012 self.body#012
File "/opt/folder/dependencies/extract_msg/message.py", line 460, in body#012 self._body = self._getStringStream('__substg1.0_1000')#012
File "/opt/folder/dependencies/extract_msg/message.py", line 166, in _getStringStream#012 return None if tmp is None else
tmp.decode(self.stringEncoding)#012UnicodeDecodeError: 'gbk' codec can't decode bytes in position 34-35: illegal multibyte sequence
我不允许共享 .msg 文件。该文件有gbk编解码器(汉字)
解决方案
推荐阅读
- javascript - 如何针对不同的条件将日期设置为 ISOString
- python - Wireshark中的Python UDP数据包不一样
- java - 使用自定义转换器推土机映射继承的类
- rhel - systemctl 因未知部分“计时器”而失败
- python - 在 tensorflow 中组合计算图
- windows - 中等时间间隔的准确时间增量:GetTickCount64 vs QueryPerformanceCounter
- python-2.7 - How to implement the 0.5*||euclidean_norm||^2?
- java - 如何使用 Spring @Value 注入 Maps
- python - Python模块运行但函数不会
- vba - 如何根据 VBA 中的条件创建工作表和工作簿?