如何使用nntplib模块?

2024-06-01 06:04:28 发布

您现在位置:Python中文网/ 问答频道 /正文

当我使用Python的nntplib模块文档中的第一个示例时,有一些错误。在

>>> from nntplib import NNTP
>>> s = NNTP('news.gmane.org')
>>> resp, count, first, last, name = s.group('gmane.comp.python.committers')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\nntplib.py", line 354, in group
    resp = self.shortcmd('GROUP ' + name)
  File "C:\Python27\lib\nntplib.py", line 268, in shortcmd
    return self.getresp()
  File "C:\Python27\lib\nntplib.py", line 223, in getresp
    resp = self.getline()
  File "C:\Python27\lib\nntplib.py", line 215, in getline
    if not line: raise EOFError
EOFError

为什么会这样?在


Tags: nameinpyselfliblinegroupresp
1条回答
网友
1楼 · 发布于 2024-06-01 06:04:28

尝试s = NNTP('news.gmane.org' ,readermode=True)

docs中所述:

If the optional flag readermode is true, then a mode reader command is sent before authentication is performed. Reader mode is sometimes necessary if you are connecting to an NNTP server on the local machine and intend to call reader-specific commands, such as group. If you get unexpected NNTPPermanentErrors, you might need to set readermode.

相关问题 更多 >