78-传参的装饰器
在装饰器里面使用函数传参:
def color(func): def red(*args): return '\033[31;1m%s\033[0m' % func(*args) return red @color def boy(name): return "Hello %s!!!" % name @color def girl(): return "Hello girl!!!" if __name__ == "__main__": print(boy('xiaoming')) print(girl())
结果输出: