def Func():
def InerFunc():
pass
return InerFunc
def decorate(func):
a=100
def wrapper():
func()
print('------------刷墙')
print('------------铺地板')
print(a)
return wrapper
@decorate
def house():
print('我是一个毛坯房。。。。')
house()
import time
islogin=False
def login():
username=input('请输入用户名:')
password=input('请输入密码:')
if username=='admin' and password=='12345':
return True
def login_required(func):
def wrapped(*args,**kwargs):
global islogin
if islogin:
func(*args,**kwargs)
else:
islogin=login()
return wrapped
@login_required
def pay(money):
print('正在付款,付款金额是:{}元'.format(money))
print('付款中......')
time.sleep(2)
print('付款完成!')
pay(100)
pay(100)