python 代码片段19

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


原文地址:https://www.cnblogs.com/yufenghou/p/5100234.html