#-*-Coding:utf-8-*-
# python:2.x
__author__ = ' Administrator '
From nntplib Import *
# nnt.group (' name ') #选择一个组的名字, returns a tuple (Rsp,ct,fst,lst,group): The number of information files returned by the server, the first and last article numbers, and the group name, all data are strings
# NNT.XHDR (' HDR ', ' artg ', [' ofile ']) #返回文章范围atrtg (header-footer format) in the article HDR header list or output to file ofile
# nnt.body (' id ', [' ofile ']) #给定的文章id可以是消息的ID (inside the angle brackets), or an article number (which is a string), returns a tuple (Rsp,anum,mid,data): Server return information, article number (string), Message ID (inside angle brackets) and list of all article rows or outputs to file ofile
# nnt.head (' id ') is similar #与body (), except that the column list in the returned tuple only contains the article title
# nnt.article (' id ') #和body (), just returns the title and content of the article in the row list in the tuple
# nnt.stat (' id ') #让文章的指针指向id (IBID., is a message ID or article number), returns a body-like tuple, but does not contain article data
# Nnt.next () #用法与stat () similar, move the article pointer to the next article, Return and stat () similar tuples
# nnt.last () #用法与stat () similar, move the article pointer to the last article, Return and stat () similar tuples
# nnt.post (' Ufile ') #上传ufile文件对象内容 (Ufile.readline ()) and published in the current newsgroup
# nnt.quit () #关闭后退出
#例子1
# NNT=NNTP (' Your.nntp.server ')
# rsp,ct,fst,lst,grp=nnt.group (' Comp.lang.python ')
# rsp,anum,mid,data=nnt.article (' 110457 ')
# for Eachline in data:
# Print Eachline
#例子2
Def p (n=5):
Import Random
Vals=sorted (Random.random () for _ in range (2*n))
VALS=[0]+VALS+[1]
For j in Range (2*n+1):
Yield vals[j:j+2]
Dalta=[x[1]-x[0] for X in P ()]
Print Dalta
Print sum (dalta)
Nntplib Basic learning of Python