首页 > 代码库 > 关于python3.X 报"import urllib.request ImportError: No module named request"错误,解决办法
关于python3.X 报"import urllib.request ImportError: No module named request"错误,解决办法
#encoding:UTF-8import urllib.requesturl = "http://www.baidu.com"data = urllib.request.urlopen(url).read()data = data.decode(‘UTF-8‘)print(data)
报错:import urllib.request ImportError: No module named request
解决办法;
#encoding:UTF-8import urlliburl = "http://www.baidu.com"data = urllib.urlopen(url).read()data = data.decode(‘UTF-8‘)print(data)
原因查询源码 (python3.5.2) ,urllib moudle中并没有request相关方法,直接是urlopen方法
from urlparse import urljoin as basejoin__all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve", "urlcleanup", "quote", "quote_plus", "unquote", "unquote_plus", "urlencode", "url2pathname", "pathname2url", "splittag", "localhost", "thishost", "ftperrors", "basejoin", "unwrap", "splittype", "splithost", "splituser", "splitpasswd", "splitport", "splitnport", "splitquery", "splitattr", "splitvalue", "getproxies"]
关于python3.X 报"import urllib.request ImportError: No module named request"错误,解决办法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。