当前位置:天才代写 > tutorial > Python教程 > python 定义和使用装饰器-python基础

python 定义和使用装饰器-python基础

2021-02-22 10:13 星期一 所属: Python教程 浏览:585

python 界定和应用装饰器

举例说明:

# 界定一个装饰器
def mydecorator(func):
    def wrapper(*args,**kw):
        print('hi,now is:')
        return func(*args,**kw)
    return wrapper

# 应用装饰器
@mydecorator
def now():
    print('2015-12-9')

now()
 

    关键字:

天才代写-代写联系方式