2018年6月23日

python type和isinstace

摘要: 共同点 type和instanceof都可以判断变量是否属于某个内建类型 运行3次 结果: 由此可见,isinstance效率更高一些 不同点 由不同点不难发现这俩函数的应用场景是不同的: type主要用于获取未知变量的类型 isinstance主要用于判断A类是否继承于B类 转自:https:// 阅读全文

posted @ 2018-06-23 14:59 么么唧唧 阅读(273) 评论(0) 推荐(0) 编辑

python re.sub

摘要: 1. 参数说明:pattern模式字符串,可以数字命名也可以name命名(\g<1>==\1)(?P<name> \g<name>) repl 替换的字符串也可以是函数 string源串 count替换的次数 flag的值为: 2.实例 阅读全文

posted @ 2018-06-23 14:36 么么唧唧 阅读(717) 评论(0) 推荐(0) 编辑

python 字符串格式化

摘要: 1,基本用法 1,正常拼串 s1 = '%s aaa %s'('alice','bob') 2.format 不带编号 s1 = '{} aaa {}' s1.format('hello','world') 带编号 s1 = '{1} aaaa {2} bbb {1}' s.format('hell 阅读全文

posted @ 2018-06-23 11:13 么么唧唧 阅读(163) 评论(0) 推荐(0) 编辑

django转发和重定向

摘要: 1 转发 HttpResponse、render 2重定向 HttpResponseRedirect、redirect 区别:转发不会改变url,改变内容 重定向会跳转另一个html redirect('manage:index') HttpResponseRedirect(reverse('man 阅读全文

posted @ 2018-06-23 11:00 么么唧唧 阅读(1445) 评论(0) 推荐(0) 编辑

python 进程间通信Queue

摘要: Queue的使用 Queue.qsize() #返回当前队列包含的消息数量 Queue.empty() #如果队列为空,返回True,反之False Queue.full() #如果队列满了,返回True,反之False Queue.get([block[, timeout]]) #获取队列中的一条 阅读全文

posted @ 2018-06-23 10:25 么么唧唧 阅读(229) 评论(0) 推荐(0) 编辑

requests 状态码

摘要: # 信息性状态码 100: ('continue',), 101: ('switching_protocols',), 102: ('processing',), 103: ('checkpoint',), 122: ('uri_too_long', 'request_uri_too_long'), 阅读全文

posted @ 2018-06-23 09:54 么么唧唧 阅读(2059) 评论(0) 推荐(0) 编辑

beautifulsoup 解析库

摘要: 1.常用解析器 2.基本用法 节点选择器 soup = BeautifulSoup(html,'lxml')print(soup.a)#选择a节点 <a class="sister" href="http://example.com/elsie" id="link1"><!-- Elsie -->< 阅读全文

posted @ 2018-06-23 09:48 么么唧唧 阅读(253) 评论(0) 推荐(0) 编辑

python测试程序耗时

摘要: 1.使用time库 例如:import time start_time = time.time() ... elapse_time = time.time() - start_time 2.ipython 使用time、timeit 例如:%time%run xxx.py %timeit%run x 阅读全文

posted @ 2018-06-23 08:46 么么唧唧 阅读(3555) 评论(0) 推荐(0) 编辑

导航