码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
python中的装饰器
python中的装饰器能够装饰函数,也能够装饰类,功能是向函数或者类加入?一些功能。类似于设计模式中的装饰模式,它能够把装饰器的功能实现部分和装饰部分分开,避免类中或者函数中冗余的代码。装饰器装饰函数:def decrator(f1): def newf(): print "strings w...
分类:编程语言   时间:2014-08-12 18:26:44    阅读次数:257
python冒泡排序
def bubble_sort(list):     for i in range(len(list)):         for j in (range(i,len(list))):             if list[j]                 temp = list[j]                 list[j] = list[i]...
分类:编程语言   时间:2014-08-12 17:27:54    阅读次数:216
python选择排序
def select_sort(list): for i in range(len(list)): position = i for j in range(i,len(list)): if list[position] > list[j]: position = j temp = list[i] list[i] = list[position] list[pos...
分类:编程语言   时间:2014-08-12 17:25:34    阅读次数:236
python插入排序
def insert_sort(list): for i in range(len(list)): while i > 0 and list[i] < list[i-1]: temp = list[i] list[i] = list[i-1] list[i-1] = temp i = i-1...
分类:编程语言   时间:2014-08-12 17:25:24    阅读次数:269
Python函数
def functionName(arg1,arg2=default_value, arg3=None): pass#函数体global关键字声明全局变量只有在形参表末尾的那些参数可以有默认参数值传递参数时可以指定赋值,如functionName(5,arg3=6,arg2=7)参数列表:参数名前....
分类:编程语言   时间:2014-08-12 16:35:24    阅读次数:239
msvc下从dll文件创建lib
1.进入msvc命令控制台。 2.生成.def文件 通过pexports或微软编译环境自带的dumpbin.exe导出DLL对应的def文件 方法一: pexports ***.dll > ***.def 方法二: dumpbin /exports ***.dll > ***.def 其中***代表你的...
分类:其他好文   时间:2014-08-12 00:55:04    阅读次数:360
#Leet Code# Permutation
描述:输出全排列代码: 1 class Solution: 2 # @param num, a list of integer 3 # @return a list of lists of integers 4 def doSth(self, num): 5 ...
分类:其他好文   时间:2014-08-11 17:10:32    阅读次数:205
python整合连续数字的练习,包含itertools\groupby用法
#汉字数字转阿拉伯数字 1 class ConvertNum: 2 def __init__(self,cnNum): 3 self.dict = {u'零':0,u'一':1,u'二':2,u'三':3,u'四':4,u'五':5,u'六':6,u'七':7,u'八':8,...
分类:编程语言   时间:2014-08-11 17:08:02    阅读次数:451
使用shell调用python中的函数
最近遇到一个需求,需要通过shell调用python中的一个函数,发现其实也挺简单的:python脚本如下:test.py:import ConfigParserconfig = ConfigParser.ConfigParser()config.read("test.conf")def get_f...
分类:编程语言   时间:2014-08-11 14:23:12    阅读次数:555
Python单例模式
所谓单例,是指一个类的实例从始至终只能被创建一次。方法1如果想使得某个类从始至终最多只有一个实例,使用__new__方法会很简单。Python中类是通过__new__来创建实例的:class Singleton(object): def __new__(cls,*args,**kwargs):...
分类:编程语言   时间:2014-08-11 02:48:31    阅读次数:311
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!