如何处理返回到 python 套接字的数据?
假设您正在远程登录 IRC 以了解其工作原理。 当您发出命令时,IRC 服务器会返回数据,告诉您它正在做什么。 一旦我创建了一个默认脚本,它基本上就是服务器和客户端之间正常 IRC 连接的发生方式,如果它偏离了它,它不会告诉我出了什么问题。 我需要能够根据服务器返回给我的内容抛出异常。 我如何在 python 中做到这一点?
Say you are telneting into IRC to figure out how it all works. As you issue commands the IRC server returns data telling you what it's doing. Once I have created a default script that basically is how a normal IRC connection between server and client occurs, if it ever deviates from that it won't tell me what is wrong. I need to be able to throw exceptions based on what the server returns to me. How do I do that in python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的教程几乎引导您使用 Python 中的套接字完成 IRC 客户端:
Here's a tutorial which pretty much walks you through an IRC client using sockets in Python:
Twisted 是一个用 Python 编写的事件驱动的网络引擎,并且包括对
IRC
协议。 要访问IRC
功能,请将其导入:请参阅示例这里:ircLogBot.py - 连接到 IRC 服务器并记录所有消息。 示例
__doc__
:Twisted is an event-driven networking engine written in Python, and includes support for
IRC
protocols. To accessIRC
functionality, import it:See an example here: ircLogBot.py - connects to an IRC server and logs all messages. The example
__doc__
: