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,'/')


posted @ 2016-01-04 21:04  yufenghou  阅读(131)  评论(0)    收藏  举报