all Python 3until 3.13Removed from the standard libraryterm
nntplib
removed modules
Client for NNTP, the Usenet newsgroup protocol. Removed in Python 3.13 — use the pynntp package and parse articles with email.
Syntax
import nntplib # до 3.13
nntplib.NNTP('news.example.com') connected to a news server: group() selected a group, over() listed articles, article() fetched one, post() published. PEP 594 dropped it: Usenet is nearly dead and the module's tests relied on a live server that disappeared. There is no stdlib replacement for the protocol: use pynntp or standard-nntplib, which restores the old module. An NNTP article is a plain RFC 5322 message, so parse it with the email package: email.message_from_bytes(raw, policy=email.policy.default) gives headers by key and the body via get_content().
Examples
# Python 3.13+
try:
import nntplib
except ModuleNotFoundError as e:
print(type(e).__name__) # → ModuleNotFoundError
# Python 3.13+
import email, email.policy
raw = b'Subject: Hello\r\nNewsgroups: comp.lang.python\r\n\r\nBody\r\n'
msg = email.message_from_bytes(raw, policy=email.policy.default)
print(msg['Subject'], msg['Newsgroups']) # → Hello comp.lang.python
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy