2010-05-05 68 views
2

如何查找使用httplib庫連接是否中斷?似乎很基本,但我無法在這裏或谷歌上找到答案。python httplib和斷開的tcp連接

+0

>>> import httplib >>> conn = httplib.HTTPConnection("www.python.org") >>> try: >>> conn.request("GET", "/index.html") >>> except Exception as e: >>> #take action according to the error. >>> print(type(e)) >>> r1 = conn.getresponse() >>> print r1.status, r1.reason 

例子一樣,答案工作? – msemelman 2010-05-06 03:29:31

回答