Python 3.x中的urllib的改动
来源:互联网 发布:在线编程app更新 编辑:程序博客网 时间:2024/05/29 13:52
在pyhon3.x中,对原来的urllib做了很多的修改。将Request,error,urllib2等都归一到了urllib中。下面就说明一些遇到的细节。
1.原来的urllib.urlopen改为urllib.request.urlopen(),而且开头的import urllib要改为import urllib.request.
2.urllib2.Request()要改为urllib.request.Request()
3.urllib.urlencode(values)改为urllib.parse.urlencode(values),最好在后面加上encode(encoding='utf_8', errors='strict')
4.urllib.URLError,e 改为urllib.error.URLError as e
另外在python 3.x中如果遇到AttributeError: 'module' object has no attribute ‘xxxx’
xxxx是出问题的属性,可能是没有import正确的包。
1 0
- Python 3.x中的urllib的改动
- 实践中Python 2.x 与 python 3.x 的改动
- Python中的urllib,urllib三种不同的请求方式
- python中的urllib模块
- python中的urllib详解
- python模块学习---urllib,urlparse(3.0以后有改动)
- python模块学习---urllib,urlparse(3.0以后有改动)
- python 3.X版本 利用urllib.request 通过制定的URL抓取网易内容
- python3.x中的urllib模块
- python3.x中的urllib模块
- Python 3.x中导入urllib出现AttributeError: module 'urllib' has no attribute 'urlopen'
- Python 的 urllib
- Python 的 urllib
- python的urllib
- Python-urllib的API
- Python的urllib
- Python 3 中的 urllib 实例
- python--urllib模块中的方法
- 冒号在MATLAB里基本意思
- 递归 八皇后复习
- 黑马程序员——Java基础---循环
- Triangle - LeetCode
- static 关键字
- Python 3.x中的urllib的改动
- struts.xml
- HDU 1158 Common Subsequence
- 单线性链表的创建,遍历以及增删查改
- hdoj 1196 Lowest Bit
- 第4周项目1三角形类的构造函数(3)
- C语言 编写函数实现内存重叠拷贝,不允许调用memmove函数
- ISSYS_MODIFIABLE 返回false
- opencv人脸识别总结三