zqifa的博客

我不管,反正我最萌~

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.xxx.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)

作者:zqifa

出处:https://www.l1mn.com

原文地址:https://www.l1mn.com/p/a0jbf3.html

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

分类:python
标签:python

公告

昵称:zqifa

站龄: 4年2个月

博客持续完善ing,敬请期待...

打滚求打赏(๑ ̄ ̫  ̄๑)

此处弱弱求打赏~~万一有好心人呢~~

支付宝酱

支付宝赞助

微信酱

微信赞助

随笔分类

php(110)

linux(63)

python(44)

web前端(39)

js(35)

服务器(33)

mysql(30)

html(24)

docker(23)

windows(22)

centos(22)

django(20)

前端设计(18)

git(16)

常用软件(14)

数据库(14)

算法(14)

字符编码(13)

编程进阶(13)

笔记(12)

更多

我的标签

php(106)

linux(47)

python(45)

js(34)

mysql(30)

centos(28)

web前端(23)

docker(22)

windows(22)

django(20)

更多

相册

Copyright © zqifa 联系方式:z___qf@163.com