随笔分类 -  python

摘要:python -v 小写v:这是版本信息,包括库版本 python -V 大写v:只看python的版本 阅读全文
posted @ 2019-09-10 14:49 任飞儿 阅读(4588) 评论(0) 推荐(1)
摘要:import xlwtworkbook = xlwt.Workbook()#创建bookworksheet = workbook.add_sheet('My Sheet') #添加sheet#背景色的添加pattern = xlwt.Pattern() # Create the Patternpat 阅读全文
posted @ 2017-11-09 16:21 任飞儿 阅读(1633) 评论(0) 推荐(0)
摘要:官网 https://pypi.python.org/pypi/xlrd 下载 解压 执行python setup.py install进行安装 setuptool工具 的安装 1. Windows 可直接通过链接 https://bitbucket.org/pypa/setuptools/down 阅读全文
posted @ 2017-11-09 11:31 任飞儿 阅读(6009) 评论(0) 推荐(0)
摘要:2.绝版线程池设计思路:运用队列queue a.队列里面放任务 b.线程一次次去取任务,线程一空闲就去取任务 import queueimport threadingimport contextlibimport time StopEvent = object() class ThreadPool( 阅读全文
posted @ 2017-10-31 10:16 任飞儿 阅读(211) 评论(0) 推荐(0)
摘要:1.low版线程池设计思路:运用队列queue 将线程类名放入队列中,执行一个就拿一个出来import queueimport threading class ThreadPool(object): def __init__(self, max_num=20): self.queue = queue 阅读全文
posted @ 2017-10-31 10:11 任飞儿 阅读(196) 评论(0) 推荐(0)
摘要:1、进程与线程优、缺点的比较总言:使用进程和线程的目的,提高执行效率。 进程: 优点:能利用机器的多核性能,同时进行多个操作。 缺点:需要耗费资源,重新开辟内存空间,耗内存。 线程: 优点:共享内存(资源),做IO操作时,可以创造并发操作。 缺点:抢占资源。 总结:进程并不是越多越好,最好CPU个数 阅读全文
posted @ 2017-10-30 16:09 任飞儿 阅读(179) 评论(0) 推荐(0)
摘要:Python中,专门用于HTML/XML解析的库; 特点是: 即使是有bug,有问题的html代码,也可以解析。 BeautifulSoup主要有两个版本 BeautifulSoup 3 之前的,比较早的,是3.x的版本。 BeautifulSoup 3的在线文档 最新的,可用的,在线文档是: ht 阅读全文
posted @ 2017-10-27 17:52 任飞儿 阅读(303) 评论(0) 推荐(0)
摘要:自python2.6开始,新增了一种格式化字符串的函数str.format() 语法 它通过{}和:来代替%。 “映射”示例 通过位置 字符串的format函数可以接受不限个参数,位置可以不按顺序,可以不用或者用多次,不过2.6不能为空{},2.7才可以。 通过关键字参数 通过对象属性 通过下标 有 阅读全文
posted @ 2017-10-27 10:46 任飞儿 阅读(193) 评论(0) 推荐(0)
摘要:获取标签名 h1 class 是h1usersoup.find(name="h1", attrs={"class":"h1user"});获取标签的内容h1userSoup.string; __str__ 使用class Student(object): def __init__(self, nam 阅读全文
posted @ 2017-10-26 17:25 任飞儿 阅读(584) 评论(0) 推荐(0)
摘要:SQLite中的时间日期函数这是我学习SQLite时做的笔记,参考并翻译了Chris Newman写的《SQLite》中的《Working with Dates and Times》部分内容。SQLite包含了如下时间/日期函数:datetime().......................产生 阅读全文
posted @ 2017-10-26 14:18 任飞儿 阅读(290) 评论(0) 推荐(0)
摘要:cx = sqlite3.connect("c:/数据库地址") # 打开数据库cu = cx.cursor()# delete the rowcu.execute("delete from user where username=='majuan'")# Save (commit) the cha 阅读全文
posted @ 2017-10-25 15:24 任飞儿 阅读(594) 评论(0) 推荐(0)
摘要:cx = sqlite3.connect("c:/数据库地址") # 打开数据库cu = cx.cursor()# query the tablerows = cu.execute("select * from user")# print the tablefor row in rows: prin 阅读全文
posted @ 2017-10-25 15:19 任飞儿 阅读(393) 评论(0) 推荐(0)
摘要:cx = sqlite3.connect("c:/数据库名字")#打开数据库cu = cx.cursor()cu.execute("INSERT INTO [user] VALUES('乔任梁', '123', '123','测试','122','111')")#新增sqlcx.commit() 阅读全文
posted @ 2017-10-25 14:14 任飞儿 阅读(629) 评论(0) 推荐(0)
摘要:Python 3.X 要使用urllib.request 来抓取网络资源。 最简单的方式: 使用Request的方式: 这种方式同样可以用来处理其他URL,例如FTP: 使用POST请求: 使用GET请求: 添加header: 错误处理: 返回的错误代码: 阅读全文
posted @ 2017-01-22 15:07 任飞儿 阅读(9271) 评论(0) 推荐(1)
摘要:python编码 一、系统默认编码 python 2.7版本系统默认编码是ascii python 3.1版本系统默认编码是unicode 可以通过内建模块sys获取系统默认编码 import sys print sys.getdefaultencoding() 有两种方法可以讲系统默认编码变成ut 阅读全文
posted @ 2017-01-11 17:07 任飞儿 阅读(197) 评论(0) 推荐(0)
摘要:特殊字符:^ $ * + ? { [ ] \ | ( ) regular expression 正则表达式 import re 简单的regexp p = re.compile("abc") if p.match("abc") : print "match" 上例中首先生成一个pattern(模式) 阅读全文
posted @ 2016-11-18 11:09 任飞儿 阅读(206) 评论(0) 推荐(0)
摘要:一、数学相关 1、绝对值:abs(-1)2、最大最小值:max([1,2,3])、min([1,2,3])3、序列长度:len('abc')、len([1,2,3])、len((1,2,3))4、取模:divmod(5,2)//(2,1)5、乘方:pow(2,3,4)//2**3/46、浮点数:ro 阅读全文
posted @ 2016-11-18 09:59 任飞儿 阅读(6352) 评论(0) 推荐(0)
摘要:[python] 常用正则表达式爬取网页信息及分析HTML标签总结 转http://blog.csdn.net/Eastmount/article/details/51082253 [python] 常用正则表达式爬取网页信息及分析HTML标签总结 转http://blog.csdn.net/Eas 阅读全文
posted @ 2016-11-11 09:08 任飞儿 阅读(1985) 评论(0) 推荐(0)
摘要:将Python脚本封装成exe可执行文件 http://www.cnblogs.com/renzo/archive/2012/01/01/2309260.html cx_freeze是用来将 Python 脚本封装成可执行程序的工具,支持最新的Python3.2版本。生成的执行文件具有跨平台性,而且 阅读全文
posted @ 2016-11-04 15:19 任飞儿 阅读(1651) 评论(0) 推荐(0)
摘要:一、技能列表 1、掌握java、尤其编程网络部分;李刚的java基础至少看了三遍以上; 2、熟悉html、js、 ajax、firedebug3、网页去重、找到网站特点4、分布式5、多线程6、一种关系型数据库mysql/oraclelserver/mybatis7、正则表达式、css selecto 阅读全文
posted @ 2016-11-03 10:10 任飞儿 阅读(366) 评论(0) 推荐(0)