urllib2和HTTPErrorProcessor Python 3

urllib2和HTTPErrorProcessor Python 3,python,python-3.x,python-2.7,kodi,Python,Python 3.x,Python 2.7,Kodi,我正在尝试将python代码从2.7更改为3.6 所以,我不熟悉python,但我对urllib2有错误 我有这个错误 Error Contents: name 'urllib2' is not defined 所以我这样做: from urllib.request import urlopen 这可能没问题,因为urllib2对phyton 3不起作用? 但我有一个: class NoRedirection(urllib2.HTTPErrorProcessor): def http_

我正在尝试将python代码从2.7更改为3.6

所以,我不熟悉python,但我对urllib2有错误 我有这个错误

Error Contents: name 'urllib2' is not defined
所以我这样做:

from urllib.request import urlopen
这可能没问题,因为urllib2对phyton 3不起作用? 但我有一个:

class NoRedirection(urllib2.HTTPErrorProcessor):
   def http_response(self, request, response):
       return response
   https_response = http_response
我试图改变的内容

class NoRedirection(urlopen.HTTPErrorProcessor):
但不起作用。如何解决此问题?

 **AttributeError: 'function' object has no attribute 'HTTPErrorProcessor'**

对于发现的错误,有一个单独的模块。你想做的就是沿着这些路线做

from urllib.error import HTTPError

class NoRedirection(HTTPError):
    ...