Nntplib Basic learning of Python

Source: Internet
Author: User
Tags nntp

#-*-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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.