如何使用 nntplib 模块?

How to use nntplib module?

当我使用 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

为什么会这样?

尝试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.