随笔分类 -  Python

摘要:```python# -*- coding:UTF-8 -*-"""遍历目录中的所有文件和目录,并生成全路径"""import ostarget_path = "D:/temp/"'''path: 遍历的路径file_type: 文件类型列表,如果为空遍历所有文件,不为空遍历指定文件如[".c", ... 阅读全文
posted @ 2015-06-30 23:08 Let it be!
摘要:## 监视文件变更```python#!/usr/bin/python# -*- coding:UTF-8 -*-import timefrom watchdog.observers import Observerfrom watchdog.events import RegexMatching... 阅读全文
posted @ 2015-06-22 22:16 Let it be!
摘要:本教程是 "A Byte of Python" 中文翻译版,是基于python3.0的,python3.0对以前版本有了较大改进,其中的内容在翻译时参考了网络上流行的《简明 Python 教程》。希望对python初学者有点帮助!Love python, love life, because python can save your life!文件下载 链接书籍 书籍下载链接代码书中所有代码latex源码 pdf文件Latex 阅读全文
posted @ 2013-04-22 23:27 Let it be!
摘要:1. 简介matplotlib official website:http://matplotlib.sourceforge.net/index.htmlThe pylab mode provides all of thepyplotplotting functions, as well as non-plotting functions fromnumpyandmatplotlib.mlab.Numpy, scipy, matplotlib, pylab之间的关系:链接numpy & scipy 的关系:首先了解下这家公司http://www.enthought.com/ 它维护着包 阅读全文
posted @ 2012-06-28 17:58 Let it be!
摘要:>>> import collections>>> a = list(range(1000000))>>> a[100] = 1 #稍微改变一下列表#方法一>>> b = filter(lambda x: a.count(x) > 1, a)#方法二>>> d = filter(lambda x: x[1] != 1,collections.Counter(a).items())为什么方法一要比方法二慢得多呢?方法一中的count()函数要O(n^2)的时间复杂度。方法二加速的原因是什么呢?到底是怎 阅读全文
posted @ 2011-10-29 01:03 Let it be!
摘要:#!/usr/bin/python#encoding:UTf-8import randomdef partition(A, p, r): x = A[r] i = p - 1 for j in range(p,r): if A[j] <= x: i = i + 1 A[i],A[j] = A[j],A[i] A[i+1],A[r] = A[r],A[i+1] return i+1def ... 阅读全文
posted @ 2011-10-17 20:00 Let it be!
摘要:1 #!/usr/bin/python 2 #coding:utf-8 3 def next_permutation(A): 4 ''' 5 input: array of a permutation of n numbers 6 output: the next permutation 7 Algorithm: dicttionary order 8 ''' 9 #print(A)10 n = len(A)11 last = n - 112 i... 阅读全文
posted @ 2011-10-01 15:29 Let it be!
摘要:import MySQLdb #注意大小写!!#建立和数据库系统的连接conn = MySQLdb.connect(host='localhost',user='root',passwd='smile',db='test')#获取操作游标cursor = conn.cursor()#执行SQL,创建一个数据库.cursor.execute("""create database python""")cursor.execute('create table test& 阅读全文
posted @ 2011-09-15 21:50 Let it be!