#成员的种类: Normal field static field normal method static method class method General characteristics
Class FFF:
x= ' xxxxxdddd '
__x1= ' x11111111 ' __ ' is a member modifier, and X1 is the modified variable field that is only accessed internally
def __init__ (self):
Print (' 111 ')
Self.__name= ' name222 ' #这个name依旧是那个私有的字段 is still not to be called
def fetch (Self,bak):
Print (BAK)
Print (FFF.__X1)
def __call__ (self, *args, **kwargs):
Print (' calll1111 ')
Class Bar (FFF):
def fetch (self):
Print (' Bbbbar ')
Bbb=bar ()
BBB ()
bbb[' K1 ']
Output ————————————————————————————————————————————————————————————————————————————————————————————————————————————— —————————————————————————————————————————————————————————
Traceback (most recent):
File "d:/users/administrator/pycharmprojects/untitled/venv/yingshe/chengyuanxiushifu.py", line A, in <module >
bbb[' K1 ']=5
TypeError: ' Bar ' object does not support item assignment
111
calll1111
This bbb[' K1 ' is an error because there is no way to call the Add Member __getitem__ ()
*************************************************************************************************************** *************************************************************************************************************** ************************************************
#成员的种类: Normal field static field normal method static method class method General characteristics
Class FFF:
x= ' xxxxxdddd '
__x1= ' x11111111 ' __ ' is a member modifier, and X1 is the modified variable field that is only accessed internally
def __init__ (self):
Print (' 111 ')
Self.__name= ' name222 ' #这个name依旧是那个私有的字段 is still not to be called
def fetch (Self,bak):
Print (BAK)
Print (FFF.__X1)
def __call__ (self, *args, **kwargs):
Print (' calll1111 ')
def __getitem__ (self, item):
Print (item)
Class Bar (FFF):
def fetch (self):
Print (' Bbbbar ')
Bbb=bar ()
BBB ()
bbb[' K1 '] #中括号 The default execution of GetItem methods and the SetItem Delitem method This set of operations is modeled after the dictionary operation
Output ————————————————————————————————————————————————————————————————————————————————————————————————————————————— —————————————————————————————————
111
calll1111
K1
Here we go, no more errors.
*************************************************************************************************************** *************************************************************************************************************** ***********************************************
#成员的种类: Normal field static field normal method static method class method General characteristics
Class FFF:
x= ' xxxxxdddd '
__x1= ' x11111111 ' __ ' is a member modifier, and X1 is the modified variable field that is only accessed internally
def __init__ (self):
Print (' 111 ')
Self.__name= ' name222 ' #这个name依旧是那个私有的字段 is still not to be called
def fetch (Self,bak):
Print (BAK)
Print (FFF.__X1)
def __call__ (self, *args, **kwargs):
Print (' calll1111 ')
def __getitem__ (self, item):
Print (item)
def __setitem__ (self, Key, value):
Print (Key,value)
Class Bar (FFF):
def fetch (self):
Print (' Bbbbar ')
Bbb=bar ()
BBB ()
bbb[' K1 ']=123
Output ————————————————————————————————————————————————————————————————————————————————————————————————————————————— —————————————————————————
111
calll1111
K1 123
*************************************************************************************************************** *************************************************************************************************************** ***********************************************
#成员的种类: Normal field static field normal method static method class method General characteristics
Class FFF:
x= ' xxxxxdddd '
__x1= ' x11111111 ' __ ' is a member modifier, and X1 is the modified variable field that is only accessed internally
def __init__ (self):
Print (' 111 ')
Self.__name= ' name222 ' #这个name依旧是那个私有的字段 is still not to be called
def fetch (Self,bak):
Print (BAK)
Print (FFF.__X1)
def __call__ (self, *args, **kwargs):
Print (' calll1111 ')
def __getitem__ (self, item):
Print (item)
def __setitem__ (self, Key, value):
Print (Key,value)
def __delitem__ (self, key):
Print (' Delitem ')
Class Bar (FFF):
def fetch (self):
Print (' Bbbbar ')
Bbb=bar ()
BBB ()
bbb[' K1 ']=123
Del bbb[' K1 ']
Output ————————————————————————————————————————————————————————————————————————————————————————————————————————————— ———————————————————————————————————————
111
calll1111
K1 123
Delitem
*************************************************************************************************************** *************************************************************************************************************** **********************************************
*************************************************************************************************************** *************************************************************************************************************** **********************************************
PYTHON_67 special Member of object-oriented class Setitem/getitem/delitem