• python 常见问题总结


    1、ModuleNotFoundError: No module named 'urllib2'

    在python3.x版本中,urllib和urllib2包集合成在一个包了
    import urllib2
    response = urllib2.urlopen(request)
    改为
    import urllib.request
    response = urllib.request.urlopen("http://www.fyunw.com")

    2、ModuleNotFoundError: No module named 'urlparse'

    3.0版本中已经将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)

    改为

    import urllib
    my_url = urllib.urlparse(url)

  • 相关阅读:
    LC 155 Min Stack
    TUM 慕尼黑工业大学 MSEI 课程结构介绍 ws19/20
    C++ MinGW 配合 Sublime Text 搭建
    LC 752 Open the Lock
    LC 200 Number of Islands
    Python lambda
    关于无法连接网络安装VisualVM解决方案
    二叉堆的解读
    哈希表的实现
    红黑树解读
  • 原文地址:https://www.cnblogs.com/zqifa/p/python-5.html
Copyright © 2020-2023  润新知