定义一个基类
class Persion(object):
def __init__(self, name):
self.name=name
def aa(fn):
def new(*args,**kwargs):
print('这一行用于判断')
fn(*args,**kwargs)
print('这一行是日志')
return new
@aa
def say(self,address):
print(self.name,address)
派生子类
class BlackPersion(Persion):
def __init__(self, name):
super().__init__(name)
@Persion.aa
def newfn(self):
print(self.name)
b=BlackPersion('zhansan')
b.say('fz')
b.newfn()
标签:__,aa,name,self,面向对象,print,def
From: https://www.cnblogs.com/wangend/p/17094450.html