标签:try success .com timeout 返回 else span except ror
import socket from urllib import request,error try: response = request.urlopen(‘https://cuiqingcai.com/index/htm‘,timeout=0.01) except error.HTTPError as e: #先捕获子类错误HTTPError print(e.reason,e.code,e.headers,sep=‘\n‘) except error.URLError as e: #再捕获父类错误URLError print(type(e.reason)) #reason有时返回对象 print(e.reason) if isinstance(e.reason,socket.timeout): print(‘TIMEOUT‘) else: print(‘Request Successfully‘)
标签:try success .com timeout 返回 else span except ror
原文地址:https://www.cnblogs.com/vector-wyw/p/10416026.html