Code Monkey home page Code Monkey logo

Comments (11)

pandolia avatar pandolia commented on July 26, 2024

我这边运行都没问题的,收发中文消息都可以,可能是版本问题,我的是 Python2.7.10 ,您的版本是多少?

from qqbot.

pandolia avatar pandolia commented on July 26, 2024

line 290 是
QLogger.info('收到一条来自 %s%d(buddy%d) 的消息: <%s>' % pollResult)
可以运行到这一行那登录和收发消息都没问题了,您把这一行注释掉,改成
print "pollResult =", pollResult
看看能否正常输出,或者改为:
QLogger.info('收到一条消息')

from qqbot.

pandolia avatar pandolia commented on July 26, 2024

非常感谢 cnbillow 提供的错误信息,根据此信息,程序在 line 290 发生错误 :

QLogger.info('收到一条来自 %s%d(buddy%d) 的消息: <%s>' % pollResult)

初步怀疑可能在低版本 Python 中、或者是接收到某些特殊的消息时会导致 UnicodeDecodeError 错误。可能在这些情况下 QLogger.info 方法接收到的不是一个 str ,而是一个 unicode ,当 QLogger.info 方法内部对接收到的 unicode 进行解码时发生了错误。

但到目前为止我还未能复现此错误,我测试了很多稀奇古怪的消息,都可以正常运行。希望 cnbillow 还能提供更详细一点的错误信息,比方说把这一行改为:

print "pollResult =", pollResult
QLogger.info('收到一条消息')
for el in pollResult: print repr(el)

看看这些代码的输出信息是什么。

from qqbot.

pandolia avatar pandolia commented on July 26, 2024

由于一直未能复现此错误,本issue暂时关闭。此错误出现在第290行:

QLogger.info('收到一条来自 %s%d(buddy%d) 的消息: <%s>' % pollResult)

表明可成功收消息,只是打印消息出错了。建议遇到同样错误的朋友将本行改为:

QLogger.info('收到一条消息' + str(pollResult))

也希望您能将错误信息提供给我,帮助我改进本程序。

from qqbot.

lvsenlin avatar lvsenlin commented on July 26, 2024

在linux下sys.getfilesystemencoding()获取到的是'ANSI_X3.4-1968',报错
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 32: ordinal not in range(128)

如下代码:
File "/usr/lib/python2.7/site-packages/qqbot/qterm.py", line 109, in QTerm
command = command.decode(sys.getfilesystemencoding())

from qqbot.

pandolia avatar pandolia commented on July 26, 2024

这里改成 sys.stdin.encoding 或者 'utf8' 有用否?

from qqbot.

lvsenlin avatar lvsenlin commented on July 26, 2024

改了编译不了,好气!centos6.5 openssl升级了,python就不正常

from qqbot.

pandolia avatar pandolia commented on July 26, 2024

用 virtual env 装吧。

from qqbot.

pandolia avatar pandolia commented on July 26, 2024

#63

from qqbot.

lvsenlin avatar lvsenlin commented on July 26, 2024

2.1.4改出问题了,如下:
Traceback (most recent call last):
File "/usr/bin/qqbot", line 9, in
load_entry_point('qqbot==2.1.4', 'console_scripts', 'qqbot')()
File "/usr/lib/python2.7/site-packages/qqbot/qqbotcls.py", line 70, in RunBot
runBot((botCls or QQBot), qq, user)
File "/usr/lib/python2.7/site-packages/qqbot/qqbotcls.py", line 39, in runBot
conf = QConf(qq, user)
File "/usr/lib/python2.7/site-packages/qqbot/qconf.py", line 75, in init
self.readCmdLine()
File "/usr/lib/python2.7/site-packages/qqbot/qconf.py", line 84, in readCmdLine
help=STR2SYSTEMSTR('指定一个配置文件项目以导入设定。USER指的是配置文\n'
File "/usr/lib/python2.7/site-packages/qqbot/common.py", line 21, in STR2SYSTEMSTR
return s if PY3 else s.decode('utf8').encode(sys.stdin.encoding)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-15: ordinal not in range(128)

from qqbot.

lvsenlin avatar lvsenlin commented on July 26, 2024

这个问题已确定,要把操作系统改为utf-8,因为是命令行传入的是ascii,所以改代码无效。

from qqbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.