2014年1月10日
摘要: 整理了日常用到的一些sqls1.插入表insert into table_B select * from table_A2.清空表truncate table test #清空表,结构还存在delete table test where ... #删除表中特定的数据drop table test #删除整表,包括结构3. 导出到文件select * from table_A where filed1 like '8422%' into outfile '/usr/local/mysql/8422.txt' fields terminated by '|| 阅读全文
posted @ 2014-01-10 10:33 大哉昆仑 阅读(217) 评论(0) 推荐(0)
  2014年1月8日
摘要: 您可能听说过,带有 yield 的函数在 Python 中被称之为 generator(生成器),何谓 generator ?我们先抛开 generator,以一个常见的编程题目来展示 yield 的概念。如何生成斐波那契數列斐波那契(Fibonacci)數列是一个非常简单的递归数列,除第一个和第二个数外,任意一个数都可由前两个数相加得到。用计算机程序输出斐波那契數列的前 N 个数是一个非常简单的问题,许多初学者都可以轻易写出如下函数:清单 1. 简单输出斐波那契數列前 N 个数 def fab(max): n, a, b = 0, 0, 1 while n >> fab(5).. 阅读全文
posted @ 2014-01-08 22:26 大哉昆仑 阅读(201) 评论(0) 推荐(0)
摘要: 1 数据结构和算法1.1 Unpacking a sequence into separate variable(解包,赋值)>>> data = [ 'ACME', 50, 91.1, (2012, 12, 21) ]>>> name, shares, price, (year, mon, day) = data#可以用下划线来替代缺省值,节省变量名>>> >>> data = [ 'ACME', 50, 91.1, (2012, 12, 21) ]>>> _, shar 阅读全文
posted @ 2014-01-08 22:04 大哉昆仑 阅读(296) 评论(0) 推荐(0)
  2013年12月6日
摘要: 1. Collection FrameworkA Collection是一组对象的集合,A collections framework 是一个表现和操作collections的体系。(1) Collection VS Collections“Collection” 是整个集合体系的根接口。“Collections” 是一个类,提供了一些静态的方法。(2)Collection 类图(3)Map 类图(4) Collection 实现2. Iterable InterfaceCollectioninterface extendsIterable实现了Iterable接口的类可以用在for循环中:A 阅读全文
posted @ 2013-12-06 15:26 大哉昆仑 阅读(145) 评论(0) 推荐(0)
  2013年12月4日
摘要: 1.(?:...) 不想保存括号里匹配项时使用The (?:...) notation should be fairly popular; with it, you can groupparts of a regex, but it does not save them for future retrieval or use.>>> re.findall(r'http://(?:\w+\.)*(\w+\.com)', 'http://google.com http://www.google.com http://code.google.com' 阅读全文
posted @ 2013-12-04 21:32 大哉昆仑 阅读(253) 评论(0) 推荐(0)
摘要: Python1. 深入Python 3 (不错的在线学习python的网站) http://woodpecker.org.cn/diveintopython3/2. 基本语法 (适合快速了解) http://www.tutorialspoint.com/python/index.htm3. Python的算法 (形象,易懂) http://interactivepython.org/courselib/static/pythonds/index.html4. Python 实战练习(强烈推荐) http://www.checkio.org5. 自然语言工具NLTK http://nl... 阅读全文
posted @ 2013-12-04 18:42 大哉昆仑 阅读(231) 评论(1) 推荐(0)
  2013年10月16日
摘要: 最好的从书本和教材上学习编程的方法是把它们读3遍!!用这种方式学习新的内容能更好的帮你理解新语言/新概念。我相信这种方式能帮助你最大限度的从书本中汲取知识——不论你看的是什么书。读第一遍我的第一遍对编程书的阅读只做到粗浅的理解。在第一遍中,我努力跟随作者的思路,让他通过例子指导我前进。我学会编程语言的语法,但不完全,我努力理解程序是如何工作的。在第一遍阅读中我不动手敲代码。我想,我之前有编程经验,在读任何编程书籍时都可以跟得上作者的思路。我并不期望在第一遍阅读后就能用这种语言编程,就能把这些新知识运用到项目中。我得到的是对这本书里的内容有了很好的感觉。(顺便说一句,我通常一次只读一章或一节,不 阅读全文
posted @ 2013-10-16 14:43 大哉昆仑 阅读(223) 评论(0) 推荐(0)
  2013年8月12日
摘要: Interface 接口An interface defines a protocol of communication between two objects.An interface declaration contains signatures, but no implementations, for a set of methods, and might also contain constant definitions.A class that implements an interface must implement all the methods declared in the 阅读全文
posted @ 2013-08-12 09:43 大哉昆仑 阅读(206) 评论(0) 推荐(0)
  2013年7月24日
摘要: 1.读文件,通过正则匹配 1 def statisticWord(): 2 line_number = 0 3 words_dict = {} 4 with open (r'D:\test\test.txt',encoding='utf-8') as a_file: 5 for line in a_file: 6 words = re.findall(r'&#\d+;|&#\d+;|&\w+;',line) 7 for word in words: 8 words_d... 阅读全文
posted @ 2013-07-24 09:55 大哉昆仑 阅读(8266) 评论(0) 推荐(0)
摘要: 1. Assertassert len(unique_characters) 10: raise AssertionError('Too many letters'2.找出不同字母>>> words = ['SEND', 'MORE', 'MONEY']>>> ''.join(words) #join 字符串连接符'SENDMOREMONEY'>>> set(''.join(words)) #set 返回不重复字符{'E& 阅读全文
posted @ 2013-07-24 09:19 大哉昆仑 阅读(317) 评论(0) 推荐(0)