Tags : Ajax  apache  awk  besttrace  bootstrap  CDN  Django  git 

常见问题

python2.7-httplib

stevezhou      2014.12.16   


python3中,httplib被http.client取代

httplib 中,类:

class httplib.HTTPConnection(host[,port[,strict[,timeoutl[,source_address]]]])

request(method,url[,body[,headers]])

getresponse()    #返回一个HTTPResponse类的实例

close()               #关闭连接

......

class httplib.HTTPResponse(sock,debuglevel=0,strict=0)

read()      #读取响应的内容

getheader(name[,default])      #返回name指定的行首内容,若无匹配首行,返回默认

getheaders()   #返回一个列表,列表元素为(header,value)

status   #状态码

reason  #状太提示字符,如: ok、not found、......

......

class httplib.HTTPMessage

异常类

HTTPException

.....

常量:

HTTP_PORT     #80

HTTPS_PORT   #443

......

参考文档:https://docs.python.org/2.7/library/httplib.html



标签 :  python包 上一篇     下一篇