admin管理员组

文章数量:1641850

原因:
python3版本中已经将urllib2、urlparse、和robotparser并入了urllib模块中,并且修改urllib模块,其中包含5个子模块,即是help()中看到的那五个名字。如下:

urllib.error:ContentTooShortError、HTTPError、URLError

urllib.parse:parseqs、parseqsl、quote、quotefrombytes、quote_plus、unquote unquoteplus、unquoteto_bytes、urldefrag、 urlencode、urljoin、 urlparse、 urlsplit、 urlunparse、 urlunsplit

urllib.request:AbstractBasicAuthHandler、 AbstractDigestAuthHandler、 BaseHandler、 CatheFTPHandler、 FTPHandler、 FancyURLopener、FileHandler、HTTPBasicAuthHandler、 HTTPCookieProcessor、HTTPDefaultErrorHandler、 HTTPDigestAuthHandler、 HTTPErrorProcessorl、 HTTPHandler、HTTPPasswordMgr、 HTTPPasswordMgrWithDefaultRealm、 HTTPRedirectHandler、HTTPSHandler、OpenerDirector、ProxyBasicAuthHandler ProxyDigestAuthHandler、 ProxyHandler、 Request、URLopener、UnknowHandler、 buildopener、 getproxies、 installopener、 pathname2url、 url2pathname、 urlcleanup、 urlopen、 urlretrieve

urllib.response:addbase、addclosehook、addinfo、addinfourl

urllib.robotparser:RobotFileParser

解决方法:

import urlparse
my_url = urlparse.urlparse(url)

改为:

from urllib.parse import urlparse

本文标签: 解决方法提示原因Moduleurlparse