码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
Python基础篇(七)
加上两个下划线变量或者方法变为私有。 >>> class Bird: ... __song = "spark" ... def sing(self): ... return self.__song ... >>> b = Bird() >>> b.sing() 'spark' ...
分类:编程语言   时间:2014-08-10 18:12:40    阅读次数:284
hdu1166敌兵布阵&&hdu1754I Hate It(线段树入门)
单点更新是最最基础的线段树,只更新叶子节点,然后把信息用pushup这个函数更新上来。http://acm.hdu.edu.cn/showproblem.php?pid=1166update单点更新,query区域求和。#include #include #include #include #def...
分类:其他好文   时间:2014-08-10 12:47:40    阅读次数:202
Python的getattr(),setattr(),delattr(),hasattr()
Python的getattr(),setattr(),delattr(),hasattr()getattr()函数是Python自省的核心函数,具体使用大体如下:获取对象引用getattrGetattr用于返回一个对象属性,或者方法classA: def__init__(self): self.na...
分类:编程语言   时间:2014-08-10 01:38:09    阅读次数:367
关于python的函数的*和**参数:
1.将足够的参数解包以后传递给函数: >def f(p1, p2, p3, p4): > ? ? print p1+p2+p3+p4 > >li = [1, 2, 3, 4] >f(*li) 10 > >tu = (1, 2, 3, 4) >f(*tu) 10 > >di = {‘p1‘:1, ‘p2‘:2, ‘p3‘:3, ‘p4‘:4} >f(**di...
分类:编程语言   时间:2014-08-09 23:25:19    阅读次数:420
poj 3461 字符串单串匹配--KMP或者字符串HASH
http://poj.org/problem?id=3461 先来一发KMP算法: #include #include #include #include #include #include #include #include using namespace std; #define ls(rt) rt*2 #define rs(rt) rt*2+1 #def...
分类:其他好文   时间:2014-08-09 21:29:29    阅读次数:278
Python 学习笔记(3)
Class:def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def ...
分类:编程语言   时间:2014-08-09 09:02:47    阅读次数:254
用python编写ios工程自动编译、打包ipa等脚本
第一次使用python请先看:http://my.oschina.net/LangZiAiFer/blog/298763 代码管理我用的是Git; 工程clone如下: def gitClone(): ? ? os.system (‘git clone https://JackMeng@bitbucket.org/xxx/goccia.gi...
分类:移动开发   时间:2014-08-08 18:35:53    阅读次数:378
hdu 4923 Room and Moor
Room and Moor Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 539    Accepted Submission(s): 147 Problem Description PM Room def...
分类:其他好文   时间:2014-08-08 09:40:45    阅读次数:221
return语言结构 VS. scala默认返回值
Scala函数默认使用最后一个语句的运行结果作为返回值。例如def distance(a:Int,b:Int):Int={ a*a+b*b}以a*a+b*b的运行结果作为返回值。这种返回值的方式渊源于其他函数式语言Lisp/Haskell等(个人猜测)。在近期工作中,我写了如下的代码:def br....
分类:其他好文   时间:2014-08-07 13:01:20    阅读次数:270
form_tag
class SwitchesController [:index, :show] def index end def show end #存储拓扑 def topo @vts = VmToSwitch.all @sts = SwitchToSwitch.all @st...
分类:其他好文   时间:2014-08-07 03:05:28    阅读次数:269
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!