Mysql学习日记-07python面向对象编程
时间:2021-07-01 10:21:17
帮助过:21人阅读
self.name = name
self.id = id
self.gender = gender
def __call__(self, *args, **kwargs): pass
def show(self):
print(self.name, self.id, self.gender)
def __getitem__(self, item): pass
def __setitem__(self, key, value): pass
def __delitem__(self, key): pass
if __name__ == ‘__main__‘:
a = person("李白", 1, "男")
print(a()) #调用__call__
print("==========================")
print(a.__dict__) #调用__dict__属性展露
print("==========================")
print(a[‘kk‘]) # __getitem__
a[‘kk‘] = 123 # __setitem__
a.show()
print("==========================")
del a[‘kk‘] # __delitem__
a.show
Mysql学习日记-07python面向对象编程
标签:**kwargs item __name__ sqlhelper dict char 两种 学习 pytho