随笔分类 - python
摘要:Pywin32: A module to support python for Win32 extensions.Basicly, it could be used to invoke all wmi class to do what you want in Windows.(http://msdn.microsoft.com/en-us/library/windows/desktop/aa394554(v=vs.85).aspx).We use this module to do network configuration, such as DNS config.However there
阅读全文
摘要:A test case for a database-backed Web site isn't much use if there isn't any data in the database. To make it easy to put test data into the database, Django's customTestCaseclass provides a way of loadingfixtures.(see detail here)Once you've created a fixture and placed it in afixtu
阅读全文
摘要:python中编码问题是一个必然会遇见的问题,尤其是中文编码,一不小心就出现乱码。为此,一个绝对不能绕过的模块codecs, 可以看出python对编码这块的支持甚是强大。另有附带codecs代码示例的博文,顺着文章一通敲下来,python中的编码问题自然就不是问题了.在使用python写一个简单爬虫的过程中,我遇见一个相关问题,也算是比较奇葩了,瞎折腾了一晚上才算是解决。本来抓取网页内容编码是 "GB2312", 传入值以后使用decode('gb2312', 'ignore')后解码为unicode,再使用Beautiful Soup进行
阅读全文
摘要:昨天面试的题目,也是很经典的问题,当时由于提问的表述有问题,直接跳过了,回来以后找到这个题目,仔细看了一下,有一个改进算法很是精妙,具体如下:原文链接:http://blog.csdn.net/anchor89/article/details/6055412题目:定义栈的数据结构,要求添加一个min函数,能够得到栈的最小元素。要求函数min、push以及pop的时间复杂度都是O(1)。注:这是06年一道Google的面试题.先来说个常规解和他的一个优化,常规解的时间复杂度符合要求,但需要线性的额外空间.常规解(参考http://zhedahht.blog.163.com/blog/static
阅读全文
摘要:1 #!/usr/bin/python 2 ## A file handling script, including functions that could search file by key 3 ## and rename file by appending key value to the file names. 4 5 import os 6 import shutil 7 import copy 8 9 def get_INV_list(key_file):10 """ read key_file and get key values into lis
阅读全文
摘要:初次接触python是在2009年秋,直到现在才有认真去学习了解。正好最近在弄工作日志,需要重复合并多个excel文档,于是折腾了一个多星期,修修补补地用python写了这么一个小东西。1.用于合并多个excel文档,可以指定是第几个工作表,默认为最后一个工作表。2.比较简陋,只是单纯地将每行数据合到一个文档中,并没有将格式也带到合并文档中。3.只能用于excel2003的文档合并。4.代码是在window下,Python自带IDEL里写的,python版本为2.7.3,具体代码如下: 1 ##2012-05-06 14:27 2 # -*- coding:utf-8 -*- 3 fro...
阅读全文

浙公网安备 33010602011771号