码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
Python快速排序
快排,取一个key值,一般取第一个即可,将小于key的放到左边,大于key的放到右边,递归实现 1 import random 2 def quicksort(data, low = 0, high = None): 3 if high == None: 4 high = l...
分类:编程语言   时间:2014-09-03 12:48:36    阅读次数:343
[译]Scala中方法和函数的区别
在Scala中函数和方法有什么区别 方法可以作为一个表达式的一部分出现(调用函数并传参),但是方法(带参方法)不能作为最终的表达式, 但是函数可以作为最终的表达式出现: scala> //定义一个方法scala> def m(x:Int) = 2*xm: (x: Int)Intscala> //定义...
分类:其他好文   时间:2014-09-03 11:04:16    阅读次数:270
python Lambda, filter, reduce and map
1. lambdaThe lambda operator or lambda function is a way to create small anonymous functions ,i.e. functions without a name. 可以方便的创造一个函数。比如 def add(.....
分类:编程语言   时间:2014-09-02 14:09:04    阅读次数:182
python 2.7 idle 配置语法提示功能
使用Python自带编辑器python IDLE的语法提示功能的配置1.C:\Python27\Lib\idlelib\config-extensions.def文件编辑[AutoComplete]enable=1popupwait=2000(改为0,语法提示等待时间)2.C:\Python27\L...
分类:编程语言   时间:2014-09-02 14:07:14    阅读次数:308
python命令行参数解析实例
闲言少述,直接上代码 ?? ?#!/usr/bin/env python # # ? import json import getopt, sys def usage():     print sys.argv[0] + ' -i irt -s status'     print sys.argv[0] + ' -i irt -n seg -t stime'     pr...
分类:编程语言   时间:2014-09-02 12:24:54    阅读次数:149
POJ2892Tunnel Warfare
写完之后各种调试各种TLE,第二天早上整理了下思路,重写了一遍,立马AC了;具体见注释 #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #def...
分类:其他好文   时间:2014-09-02 12:24:44    阅读次数:147
OpenStack_Swift源代码分析——ObjectReplicator源代码分析(2)
1、Replicator运行代码具体分析上篇问中介绍了启动Replicator的详细过程,以下解说Replicator的运行代码的详细实现,首先看replicate方法:def replicate(self, override_devices=None, override_partitions=No...
分类:编程语言   时间:2014-09-02 11:53:54    阅读次数:244
rails 在迭代里的那些条件
如果你在迭代里有一个条件,而这个条件需要查数据表来获得结果。那么请添加一个方法,比如:def checked?
分类:其他好文   时间:2014-09-01 21:00:33    阅读次数:190
使用python向Redis批量导入数据
1.使用pipeline进行批量导入数据。包含先使用rpush插入数据,然后使用expire改动过期时间class Redis_Handler(Handler): def connect(self): #print self.host,self.port,self.table self.conn.....
分类:编程语言   时间:2014-09-01 19:11:53    阅读次数:322
wxPython treeCtrl树节点递归遍历(复制)
下面是递归遍历、获取树节点的方法。 1 def getTreeAllText(self): 2 '''获取树控件的全部文本''' 3 result = [] 4 treeRoot = self.treeCtrl.GetRootItem() 5 ...
分类:编程语言   时间:2014-09-01 17:20:43    阅读次数:183
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!