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代码补全——链表
通过补全代码可以更深刻的体会到,链表就是一个存储方式,通过一单元的存储指向下一单元,而查看单元内容通过头部开始的指针依次遍历.这是leetcode里融合两个链表的题目,具体代码如下: #encodin ...
- android:保存用户名密码等应用程序数据
转自http://blog.sina.com.cn/s/blog_a73687bc0101dsjj.html (一)使用SharedPreferences 1.保存信息: SharedPrefere ...
- BZOJ 3597 SCOI2014 方伯伯送椰子 网络流分析+SPFA
原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3597 Description 四川的方伯伯为了致富,决定引进海南的椰子树.方伯伯的椰子园十 ...
- js保留两位小数,不四舍五入
//不进行四舍五入,保留两位小数 function getKeepTwoDecimals(val) { var newVal = (parseInt(val * 100) / 100).toFixed ...
- 总结const
int b; const int *a=&b; int const * a=&b; int * const a =&b; const int *const a=&b; ...
- hw_breakpoint使用方法
hw_breakpoint 使用方法 kprobe在 do_page_fault 函数中不能使用,那么如果真要在这里打点怎么办呢?看看hw_breakpoint是否可用: 事实证明,即便 hw_bre ...
- P4462 [CQOI2018]异或序列
题目描述 已知一个长度为n的整数数列 a1,a2,...,ana_1,a_2,...,a_na1,a2,...,an ,给定查询参数l.r,问在 al,al+1,...,ara_l,a_{l+1 ...
- 【题解】CQOI2015选数
这题做的时候接连想错了好多次……但是回到正轨上之后依然是一个套路题.(不过这题好像有比莫比乌斯反演更好的做法,莫比乌斯反演貌似是某种能过的暴力ヽ(´ー`)┌)不过能过也就行了吧哈哈. 首先我们把数字的 ...
- 【题解】ZJOI2007报表统计
洛谷传送门 主要思路大概也是差不多的,对于两种询问分别用线段树与平衡树来维护. 1.MIN_SORT_GAP:显然平衡树简单操作,来一发前驱.后继即可. 2.MIN_GAP:这一个我用的是线段树:可以 ...
- [bzoj2621] [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper
题目链接 状压\(dp\) 根据套路,先设\(f[sta]\)为状态为\(sta\)时所用的最小分组数. 可以发现,这个状态不好转移,无法判断是否可以装下新的一个物品.于是再设一个状态\(g[sta] ...