标签:print elf ini logs war foo pre __init__ self
class Foo: def __init__(self): pass def __call__(self, *args, **kwargs): pass def __getitem__(self, item): print(item) pass def __setitem__(self, key, value): print(key,value) pass def __delitem__(self, key): pass # 调用__int__方法 Foo() # 调用__call__方法 obj = Foo() obj() #调用__getitem__方法 obj = Foo() obj[‘k1‘] #调用__setitem__方法 obj = Foo() obj[‘k1‘] = 123 #__delitem__ obj = Foo() del obj[‘k1‘]
标签:print elf ini logs war foo pre __init__ self
原文地址:http://www.cnblogs.com/cloniu/p/6375462.html