python 代码片段20

#coding=utf-8

# 函数
def foo(x):
    print x

foo(123)


#

import httplib
def check_web_server(host,port,path):
    h=httplib.HTTPConnection(host,port)
    h.request('GET',path)
    resp=h.getresponse()
    print 'HTTP Reponse:'
    print ' status=',resp.status
    print ' reason=',resp.reason
    print 'HTTP Headers:'
    for hdr in resp.getheaders():
        print ' %s:%s ' % hdr

check_web_server('www.python.org',80,'/')

你可能感兴趣的:(python 代码片段20)