listing23-1.py

来自「《Beginning Python--From Novice to Profes」· Python 代码 · 共 30 行

PY
30
字号
from nntplib import NNTPfrom time import strftime, time, localtimeday = 24 * 60 * 60 # Number of seconds in one dayyesterday = localtime(time() - day)date = strftime('%y%m%d', yesterday)hour = strftime('%H%M%S', yesterday)servername = 'news.foo.bar'group = 'comp.lang.python.announce'server = NNTP(servername)ids = server.newnews(group, date, hour)[1]for id in ids:    head = server.head(id)[3]    for line in head:        if line.lower().startswith('subject:'):            subject = line[9:]            break    body = server.body(id)[3]    print subject    print '-'*len(subject)    print '\n'.join(body)server.quit()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?