Python3.x:关于urllib中urlopen报错问题的解决方案
Python3.x:关于urllib中urlopen报错问题的解决方案
调用:urllib.urlopen(url)
报错:AttributeError: 'module' object has no attribute 'urlopen'
原因:
1,官方文档的解释:

官方3.0版本已经把urllib2,urlparse等五个模块都并入了urllib中,也就是整合了。
2,正确的使用方法:
import urllib.request
url = "http://www.baidu.com"
get = urllib.request.urlopen(url).read()
print(get)
Python3.x:关于urllib中urlopen报错问题的解决方案的更多相关文章
- python2中的unicode()函数在python3中会报错:
python2中的unicode()函数在python3中会报错:NameError: name 'unicode' is not defined There is no such name in P ...
- 关于Entity Framework中的Attached报错的完美解决方案终极版
之前发表过一篇文章题为<关于Entity Framework中的Attached报错的完美解决方案>,那篇文章确实能解决单个实体在进行更新.删除时Attached的报错,注意我这里说的单个 ...
- IE对象最后一个属性后不要加逗号,否则在IE7及以下版本中会报错
某函数返回一个对象,如果在最后一个属性后加逗号,IE7及以下版本中会报错 正确代码: return{ top:rect.top-top, bottom:rect.bottom-top, left:re ...
- iOS-C文件添加到iOS项目中,运行报错
iOS-C文件添加到iOS项目中,运行报错 问题: 往项目中添加一个空的c文件, 编译运行; 出现2,30个编译错误. 原因: 由于在项目中添加了Pch文件,在文件中所有代码还没有开始运行之前, pc ...
- maven web 项目中启动报错 Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
主要原因是maven项目里面的jar包吗,没有导入到项目中 maven web 项目中启动报错 Java.lang.ClassNotFoundException: org.springframewor ...
- java中JDBC报错(一)
java中JDBC报错(一) 1.具体报错如下 com.mysql.jdbc.MySqlDataTruncation:Data truncation:Data too long for column ...
- IntelliJ IDEA中项目报错org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 8 或maven操作compile报resource使用utf8这样的编码错
问题:项目开发工具已经setting成utf-8 并且项目各方面的配置文件包括maven这些的pom.xml里的配置都已经设置为utf-8 但是还报错 IntelliJ IDEA中项目报错org.xm ...
- maven项目中的报错问题——Dynamic Web Module 3.0 requires Java 1.6 or newer.
转自:http://www.cnblogs.com/beppezhang/p/5919221.html maven项目中的报错问题——Dynamic Web Module 3.0 requires J ...
- 基于Postman中的报错
Postman中的报错: Could not get any response 错误 Could not get any response There was an error connecting ...
随机推荐
- POJ 1180 - Batch Scheduling - [斜率DP]
题目链接:http://poj.org/problem?id=1180 Description There is a sequence of N jobs to be processed on one ...
- HDU 4352 - XHXJ's LIS - [数位DP][LIS问题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4352 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- JSON.stringify() 格式化 输出log
调试程序的过程中,我们打印一个日志: console.log(object);,其中object是任意的一个json对象. 在控制台就会看到[object object],而看不到具体的内容. 我们可 ...
- ubuntu x64 debootstrap
sudo debootstrap jessie /mnt/jessie http://mirrors.163.com/debian
- Docker基本命令与使用 —— Dockerfile指令与构建(三)
一.Dockerfile指令上 1.指令格式 # Comment 注释, 以#开头 INSTRUCTION argument 以大写的指令+参数 #First Dockerfile 注释 FROM u ...
- 使用TensorFlow Serving优化TensorFlow模型
使用TensorFlow Serving优化TensorFlow模型 https://www.tensorflowers.cn/t/7464 https://mp.weixin.qq.com/s/qO ...
- debug $mysqli->character_set_name();
<?php $mysqli = new mysqli('localhost', 'root', '', 'w'); if(mysqli_connect_errno()){ printf('Con ...
- render, render_to_response, redirect,
自django1.3开始:render()方法是render_to_response的一个崭新的快捷方式,前者会自动使用RequestContext.而后者必须coding出来,这是最明显的区别,当然 ...
- Spark-自定义排序
一.自定义排序规则-封装类 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /** ...
- li设置float后ul无法包裹li问题解决
解决办法:灰常简单,只需给ul添加样式 ul{ overflow: auto; } 即可