gpt4 book ai didi

python - 使用 Python 3 进行 Asyncore 数据处理

转载 作者:太空宇宙 更新时间:2023-11-04 10:59:45 25 4
gpt4 key购买 nike

我正在使用 asynchat 并尝试使用 python3。收到此错误:

    error: uncaptured python exception, closing channel <irc.IRC connected
at 0x9a5286c> (<class 'AttributeError'>:'str' object has no attribute
'more' [/usr/lib/python3.2/asyncore.py|write|89] [/usr/lib/python3.2
/asyncore.py|handle_write_event|462] [/usr/lib/python3.2asynchat.py|
handle_write|194] [/usr/lib/python3.2/asynchat.py|initiate_send|245])

我的代码在 Python 2.6.7 上运行良好。

有什么建议吗?

更新:我检查过我确实在使用 python3 的异步聊天。

    ~$ python3
Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import asynchat
>>> asynchat
<module 'asynchat' from '/usr/lib/python3.2/asynchat.py'>
>>>

最佳答案

根据 http://bugs.python.org/issue12523

Actually, the error is that in Python 3 you should use bytes objects when transmitting/receiving data over the network, not (unicode) strings. That is, replace '\r\n' with b'\r\n', etc.

Of course, the error message should be made less obscure.

关于python - 使用 Python 3 进行 Asyncore 数据处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6624651/

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