1.The most simple decorator
[in]
def login(func):
print('a')
return func
@login
def func1():
print('my first function')
func1()
[out]
a
my first function
2.strengthen
[in]
def login(func):
def inner():
print('a')
print('b')
return func()
return inner
@login
def func1():
print('my first function')
func1()
[out]
a
b
my first function
*1.return is a function,not the result of function running*
2.renturn a new function