zoukankan      html  css  js  c++  java
  • 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)

  • 相关阅读:
    Merge Sorted Array
    Remove Duplicates from Sorted List
    Integer to Roman
    String to Integer (atoi)
    Valid Parentheses
    3Sum
    Remove Duplicates from Sorted Array
    Swap Nodes in Pairs
    得到一个Object的属性
    在WebGrid中做 批量删除操作
  • 原文地址:https://www.cnblogs.com/zqifa/p/python-5.html
Copyright © 2011-2022 走看看