gpt4 book ai didi

python - Logentries - Python 示例返回 UnicodeDecodeError

转载 作者:太空宇宙 更新时间:2023-11-03 17:10:31 24 4
gpt4 key购买 nike

我正在尝试设置一个“logentries”帐户来记录我的 python 开发事件。但即使使用文档中提供的最简单的测试,我也会收到以下错误。有什么想法吗?

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> from logentries import LogentriesHandler
>>> import logging
>>> log = logging.getLogger('logentries')
>>> log.setLevel(logging.INFO)
>>> log.addHandler(LogentriesHandler('xxxx-xxxx-xxxx-xxxx-xxxx'))
>>> log.info('teste')
LE: Starting Logentries Asynchronous Socket Appender
>>> Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "C:\Python27\lib\site-packages\logentries\utils.py", line 96, in run
multiline = le_helpers.create_unicode(data).replace(
File "C:\Python27\lib\site-packages\logentries\helpers.py", line 31, in create
_unicode
return unicode(ch, 'utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe1 in position 59: invalid
continuation byte

最佳答案

感谢 Nikita 的评论,我可以找到问题所在。

logentries 中的 Helpers.py 库不适合拉丁语言操作系统,其时间戳标签具有特殊字母“á”。

更换

unicode(ch,'utf8')

unicode(ch,'utf8','replace')

成功了。

关于python - Logentries - Python 示例返回 UnicodeDecodeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34139655/

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