當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python nntplib.NNTP.article用法及代碼示例

用法:

NNTP.article(message_spec=None, *, file=None)

發送 ARTICLE 命令,其中 message_specstat() 的含義相同。返回一個元組 (response, info) 其中 info 是具有三個屬性 numbermessage_idlinesnamedtuple (按此順序)。 number 是組中的文章編號(如果信息不可用,則為 0),message_id 是字符串形式的消息 ID,lines 是包含標題的原始消息的行列表(沒有終止換行符)與身體。

>>> resp, info = s.article('<20030112190404.GE29873@epoch.metaslash.com>')
>>> info.number
0
>>> info.message_id
'<20030112190404.GE29873@epoch.metaslash.com>'
>>> len(info.lines)
65
>>> info.lines[0]
b'Path: main.gmane.org!not-for-mail'
>>> info.lines[1]
b'From: Neal Norwitz <neal@metaslash.com>'
>>> info.lines[-3:]
[b'There is a patch for 2.3 as well as 2.2.', b'', b'Neal']

相關用法


注:本文由純淨天空篩選整理自python.org大神的英文原創作品 nntplib.NNTP.article。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。