Python urllib2.urlopen-打开url时出错

Python urllib2.urlopen-打开url时出错,python,python-3.3,Python,Python 3.3,我用wing101和python 3.3.2编写了以下内容 def open_page(url): """Open the URL string given and return its contents as file.""" page = None increment_num_calls() cont = False while not cont: try: page = urllib2.urlopen(url)

我用wing101和python 3.3.2编写了以下内容

def open_page(url):
    """Open the URL string given and return its contents as file."""
    page = None
    increment_num_calls()
    cont = False
    while not cont:
        try:
            page = urllib2.urlopen(url)
            cont = True
        except urllib2.URLError as e:
            print "Warning: Url load error " + str(e) + " for url " + url
            #if not hasattr(e, "code"):
            #    raise
            if hasattr(e, "code") and e.code == 401:
                return None
            time.sleep(TIME_DELAY_PAGE_RETRY)
            return None
        except httplib.BadStatusLine:
            return None
    return page
有人能帮我找出错误所说的错误吗

print "Warning: Url load error " + str(e) + " for url " + url

如果你想看更多的程序,请告诉我,我可以发布它。

打印在Python 3中的工作方式不同

试着改变

print "Warning: Url load error " + str(e) + " for url " + url


请不要添加您的电子邮件,并将答案发送到您的问题。不是这样的。请使用pythonSrsly-5的3.3.2版发布实际错误-3是足够的ppl。这家伙是新来的。@RickyDaniels print是py3.x中的一个函数。其次,我认为urllib2在py3.x中不起作用。
print('Warning: Url load error {} for url {}'.format(e, url))