摘要: 1. bookstore.py#encoding:utf-8'''根据一个给定的XML Schema,使用DOM树的形式从空白文件生成一个XML。'''from xml.dom.minidom import Documentdoc = Document() #创建DOM文档对象bookstore = doc.createElement('bookstore') #创建根元素bookstore.setAttribute('xmlns:xsi',"http://www.w3.org/2001/XMLSchem 阅读全文
posted @ 2011-10-29 23:03 Let it be! 阅读(28506) 评论(0) 推荐(0) 编辑
摘要: >>> 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! 阅读(374) 评论(0) 推荐(0) 编辑