该2to3的转换你的源代码时,Python3的另外请注意,该工具会自动适应进口urllib.request.urlopen()在Python3功能相当于urllib2.urlopen()并且urllib.urlopen
该urllib2模块定义了以下功能: urllib2.urlopen(url[,data[,timeout[,cafile[,capath[,cadefault[,context]]]]]) 打开URLurl
():#Ifthetrainingandtestsetsaren'tstoredlocally,downloadthem.ifnotos.path.exists(IRIS_TRAINING):raw=urlopen
yieldthingfinally:thing.close() 并让你编写这样的代码: fromcontextlibimportclosingimporturllibwithclosing(urllib.urlopen
该响应对象(到一个呼叫的通常的结果urllib2.urlopen(),或类似的)应支持的info()方法,该方法用一个返回对象getallmatchingheaders()的方法(通常是一个mimetools.Message