python基础===python3中 http.client 和 urllib的那些事
import http.client
#python3中没有了 httplib的库
#python 3.x中urllib库和urilib2库合并成了urllib库。。
#其中urllib2.urlopen()变成了urllib.request.urlopen()
# urllib2.Request()变成了urllib.request.Request() http_client = None http_client = http.client.HTTPConnection('localhost',8080,timeout=30) http_client.request('GET','/jenkins/api/json?pretty=true') response = http_client.getresponse()
print(response.status)
print(response.read())
等同于:
import urllib.request
response1 = urllib.request.urlopen("http://localhost:8080/?auto_refresh=true")
print(response1.read())
python基础===python3中 http.client 和 urllib的那些事的更多相关文章
- Python基础(中)
前言 print(" _ooOoo_ ") print(" o8888888o ") print(" 88 . 88 ") print(&q ...
- 13-python基础—python3中的map()
map() 会根据提供的函数对指定序列做映射. 第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表. 通俗解释: m ...
- 12-python基础—python3中的reduce()
在 Python3 中,reduce() 函数已经被从全局名字空间里移除了,它现在被放置在 functools 模块里,需要通过引入 functools 模块来调用 reduce() 函数: from ...
- 【Python】python3中urllib爬虫开发
以下是三种方法 ①First Method 最简单的方法 ②添加data,http header 使用Request对象 ③CookieJar import urllib.request from h ...
- Python 基础教程中的问题及解决方案(1)
1. 在ubuntu中,调用终端时如: f = open('/home/theone/test_input.txt', 'r') 中的txt格式文本不能加后缀 正确的应为: f = open('/h ...
- 【python】Python3中出现'gbk' codec can't encode characte的成功解决方法?
亲身测试,所遇问题完全解决!2018/07/08 21:37 环境:windows,Pycharm,python3.6.2 使用Python写文件的时候,或者将网络数据流写入到本地文件的时候,大部分情 ...
- 14-python基础—python3中的defaultdict()
1.collections.defaultdict 类 from collections import defaultdict 2.collections.defaultdict 类与工厂函数dict ...
- 【Python】Python3中的str和bytes
参考文章:Python 3的bytes/str之别 len()函数计算的是str的字符数,如果换成bytes,len()函数就计算字节数 >>> len('ABC') 3 >& ...
- python基础===python3 get和post请求(转载)
get请求 #encoding:UTF-8 importurllib importurllib.request data={} data['name']='aaa' url_parame=urllib ...
随机推荐
- [leetcode-644-Maximum Average Subarray II]
Given an array consisting of n integers, find the contiguous subarray whose length is greater than o ...
- php自学笔记2
php运行原理: 如果请求服务器上的资源是html网页,服务器直接将网页响应给客户端浏览器: 如果请求服务器上的资源是php,服务器先解释执行php,解释为标准的html代码响应给客户端浏览器.php ...
- ubuntu 和 centOS 的apache设置
更改ubuntu的网站访问根目录: 在sudo gedit /etc/apache2/sites-enabled/000-default,把 DocumentRoot /var/www #这 ...
- mysql初识(5)
将mysql数据库内的表导出为execel格式文件: 方法1:mysql命令:select * into outfile '/tmp/test.xls' from table_name;(需要注意的是 ...
- Spring Boot学习(二):配置文件
目录 前言 方式1:通过配置绑定对象的方式 方式2:@Value("${blog.author}")的形式获取属性值 相关说明 注解@Value的说明 参考 前言 Spring B ...
- lintcode-86-二叉查找树迭代器
86-二叉查找树迭代器 设计实现一个带有下列属性的二叉查找树的迭代器: 元素按照递增的顺序被访问(比如中序遍历) next()和hasNext()的询问操作要求均摊时间复杂度是O(1) 样例 对于下列 ...
- WEB-INF目录
背景: 在项目中,使用 "${pageContext.request.contextPath}/image/01.jpg"获取不到该图片.在浏览器中直接输入地址也找不到,报错404 ...
- 从零开始配置Jenkins(一)——基本配置
[背景] 由于项目变动,需要重新搭建jenkins环境,并在新搭建的平台下进行配置.之前,小编只是照猫画虎的用jenkins手动构建,虽然也维护过一段时间,但对于其中的原理并不是很了解.这下可好了,学 ...
- DataBase -- Customers Who Never Order
Question: Suppose that a website contains two tables, the Customers table and the Orders table. Writ ...
- [51nod1503]猪和回文 DP
---题面--- 题解: 首先观察到题目要求的是合法回文串的个数,而回文串要求从前往后和从后往前是一样的,因此我们假设有两只猪,分别从左上和右下开始走,走相同的步数最后相遇,那么它们走的路能拼在一起构 ...