class S(object): def Test(self): print("TEST") @classmethod def Test02(cls): print("class") @staticmethod def Test03(): print("Test03")class Test2(S): ...
分类:
编程语言 时间:
2016-05-19 18:57:05
阅读次数:
192
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5646 Accepted: 1226 Description In an edge-weighted tree, the xor-length of a path p is def ...
分类:
其他好文 时间:
2016-05-19 10:38:41
阅读次数:
230
1.hasattr和getattr#!/usr/bin/envpython
#-*-coding:utf-8–*-
importsys
classWebServer(object):
def__init__(self,host,port):
self.ip=host
self.port=port
defstart(self):
print("startserver..")
defstop(self):
print("stopserver..")
defrestart(self):
self.st..
分类:
编程语言 时间:
2016-05-19 06:48:48
阅读次数:
206
方法非常简单,用isinstance函数识别出变量类型,递归调用函数分解到原子类型的变量,序列化。 缺点是递归调用会有函数栈,复杂的对象可能占用较大内存 """ 继承自simplejson的编码基类,用于处理复杂类型的编码"""def JsonCode(obj): def _any(obj): re... ...
分类:
编程语言 时间:
2016-05-18 23:41:45
阅读次数:
276
在前两节中,我们通过一个简单的例子从服务器端的角度简要的研究了twisted的源码。在本节,我们将通过另外一个例子,从客户端的角度研究twisted的相关源码,完整例子在这里下面是简化的代码:class PoetryProtocol(Protocol): poem = '' def dataReceived(self, data):
self.poem += data...
分类:
其他好文 时间:
2016-05-18 19:35:39
阅读次数:
196
继续《nova boot代码流程分析(三):nova与neutron的交互(1)》的分析。
#/nova/virt/libvirt/driver.py:LibvirtDriver
# NOTE(ilyaalekseyev): Implementation like in multinics
# for xenapi(tr3buchet)
def spawn(self, c...
分类:
其他好文 时间:
2016-05-18 19:20:04
阅读次数:
217
from pytz import timezone def datetime_as_timezone(date_time, time_zone): tz = timezone(time_zone) utc = timezone('UTC') return date_time.replace(tzin ...
分类:
编程语言 时间:
2016-05-18 14:11:56
阅读次数:
325
polygon_vertex=[5,-7,4,2]polygon_side=['+','+','*','*'] multi_list = [[[0 for col in range(5)] for row in range(5)] for i in range(5)] def get_min_of_ ...
分类:
其他好文 时间:
2016-05-17 19:12:18
阅读次数:
146
python 最近出错总结: 1.而for..in ..中不要用else if x in y: print else: print2.def fibs(num): ... result = [0,1] ... for i in range(num-2): ... result.append(resu ...
分类:
编程语言 时间:
2016-05-17 17:41:29
阅读次数:
156
已知: $\triangle{ABC}$ 是正三角形, $AD = BE = CF$. 求证: $\triangle{DEF}$ 为正三角形. 分析: 作 $\triangle{ABC}$ 之外接圆 $\odot{O}$, 并延长 $AD, BE, CF$ 与对边及外接圆分别交于两点。 若结论成立, ...
分类:
其他好文 时间:
2016-05-17 15:58:03
阅读次数:
247