加上两个下划线变量或者方法变为私有。 >>> class Bird: ... __song = "spark" ... def sing(self): ... return self.__song ... >>> b = Bird() >>> b.sing() 'spark' ...
分类:
编程语言 时间:
2014-08-10 18:12:40
阅读次数:
284
单点更新是最最基础的线段树,只更新叶子节点,然后把信息用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()getattr()函数是Python自省的核心函数,具体使用大体如下:获取对象引用getattrGetattr用于返回一个对象属性,或者方法classA: def__init__(self): self.na...
分类:
编程语言 时间:
2014-08-10 01:38:09
阅读次数:
367
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
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
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请先看: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
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
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
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