python2 urllib2_python2.7 urllib和urllib2
urllib模块url编码和解码:
1.urllib.quote,urllib.quote_plus ,urllib.unquote ,urllib.unquote_plus
urllib.quote 说明:
quote(s, safe=‘/‘)
quote(‘abc def‘) -> ‘abc%20def‘
Each part of a URL, e.g. the path info, the query, etc., has a
different set of reserved characters that must be quoted.
RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
the following reserved characters.
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
"$" | ","
Each of these characters is reserved in some component of a URL,
but not necessarily in all of them.
By default, the quote function is intended for quoting the path
section of a URL. Thus, it will not encode ‘/‘. This character
is reserved, but in typical usage the quote function is being
called on a path where the existing slash characters are used as
reserved characters.
(END)
urllib.quote_plus 说明:
quote_plus(s, safe=‘‘)
Quote the query fragment of a URL; replacing ‘ ‘ with ‘+‘
实例演示:
In [18]: urllib.quote(‘abc def‘)
Out[18]: ‘abc%20def‘
In [19]: urllib.quote_plus(‘abc def‘)
Out[19]: ‘abc+def‘
2.urllib.urlencode
urlencode(query, doseq=0)
Encode a sequence of two-element tuples or dictionary into a URL query string.
If any values in the query arg are sequences and doseq is true, each
sequence element is converted to a separate parameter.
If the query arg is a sequence of two-element tuples, the order of the
parameters in the output will match the order of parameters in the
input.
(END)
实例演示:
In [21]: urllib.urlencode({‘username‘:‘xixi‘,‘passward‘:‘haha‘})
Out[21]: ‘username=xixi&passward=haha‘
In [23]: urllib.urlencode(((‘username‘,‘嘻嘻‘),(‘passward‘,‘哈哈‘)))
Out[23]: ‘username=%E5%98%BB%E5%98%BB&passward=%E5%93%88%E5%93%88‘
python2 urllib2_python2.7 urllib和urllib2相关推荐
- python2.7下的urllib和urllib2
python最恶心的地方就在于它的版本和配置了,特别是安装第三方包的时候经常会出现莫名其妙的错误,又不懂. 所以只能不断的切来切去的. 今天学习python爬虫,其中Python2.7使用了urlli ...
- python的网络请求库urllib、urllib2、urllib3、request的联系
文章目录 1. 简介 2. urllib 3. urllib2 4. urllib3 5. requests 6. 相关文章 1. 简介 urllib.urllib2.urllib3.request均 ...
- urllib,urllib2,urllib3区别
python3中也有urllib和urllib3两个库,其中urllib几乎是python2.7中urllib和urllib2两个模块的集合,所以我们最常用的urllib模块,而urllib3则作为一 ...
- python2 urllib模块_python urllib与urllib2模块用法教程
python urllib与urllib2模块用法 urllib 和urllib2都是接受URL请求的相关模块,但是提供了不同的功能. urllib提供urlencode方法用来GET查询字符串的产生 ...
- python3对urllib和urllib2进行了重构
python3对urllib和urllib2进行了重构,拆分成了urllib.request,urllib.response, urllib.parse, urllib.error等几个子模块,这样的 ...
- python之HTTP处理模块urllib和urllib2
python2主要涉及两个模块来处理HTTP请求:urllib和urllib2 urllib模块: urllib.urlopen(url[,data[,proxies]]) 打开一个url的方法 ...
- python网络爬虫系列教程——python中urllib、urllib2、cookie模块应用全解
全栈工程师开发手册 (作者:栾鹏) python教程全解 python数据挖掘库urllib.urllib2.cookie知识全解.本文使用python2.7环境,如果需要使用python3的环境只需 ...
- urllib和urllib2的区别(很全面详细!)
文章摘自:https://www.cnblogs.com/wly923/archive/2013/05/07/3057122.html urllib与urllib2的学习总结(python2.7.X) ...
- urllib、urllib2、urllib3 和 requests 模块有什么区别?
问: 在 Python 中,urllib.urllib2.urllib3 和 requests 模块有什么区别?为什么有三个?他们似乎在做同样的事情- 答1: HuntsBot周刊–不定时分享成功产品 ...
最新文章
- xml常用操作(js、sql、vb)
- deep_ocr 是使得 OCR 比 tesseract 更好的中文识别、身份证识别等等
- 2021年AI关键趋势,AI芯片初创公司可能发生并购
- 神经网络的设计与分析之概述
- TNNLS 22|分数不是关键,排名才是关键:针对排行榜的模型“行为”保持与灾难性遗忘的克服...
- jsencrypt加密同一值返回不同密文_密码学原语如何应用?解析密文同态性的妙用...
- 数据结构四——散列表(上)
- 为什么不能同时用const和static修饰成员函数?
- 最后一周 | 微生物组-扩增子16S分析第9期(报名直播课免费参加线下2020.8)
- 如何简单区分web前后端与MVC框架
- java异步编程的面试_去年去阿里面试,被问到java 多线程,我是这样手撕面试官的...
- ZK(1)——分布式系统概念与ZK简介
- matlab卡方拟合优度检验,卡方拟合优度检验在教学中的应用及Matlab实现_刘泽显...
- Ubuntu 9.04下安装飞信LibFetion V1.1版
- 商户如何接入微信支付
- 英文投稿的一点经验【转载】
- Null(空值)和 Undefined(未定义)
- 【实用软件】多功能游戏工具箱-Watt Toolkit
- 关于web前端大作业的HTML网页设计——我的班级网页HTML+CSS+JavaScript
- rtx3050显卡什么水平 rtx3050显卡相当于GTX什么级别
热门文章
- ajax将数据显示在class为content的标签中_[原创]数据可视化实战项目
- mysql close 出错_MySQL错误Forcing close of thread的两种解决方法
- 加载类_JVM类加载
- navicat无法连接mysql
- Specificity考量
- 【hiho挑战赛24 ABC】贪心和期望dp惨烈的后缀自动机
- 向量积 和 它的计算_7
- 电脑突然无法播放html音频,电脑无法播放音频怎么办
- mit oracle 350平衡线,MIT MI-350 CVT 平衡线_已售器材欣赏区_信谊音响_二手音响_音响发烧站_高级音响 - 音响贵族网...
- python自己写包_封装属于自己的Python包