python 代码片段20

时间:2023-12-13 14:59:26
#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,'/')