import time
defcall_out(timeout=0):defcheck_login(func):defwrapper(*args,**kwargs):print("-------1--------")
time.sleep(timeout)
ret = func(*args,**kwargs)print("--------2-----------")return ret
return wrapper
return check_login
@call_out(2)defprint_hello():print("hello world")return"ok"print(print_hello())
2. 输出结果
C:\Users\HuJun\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/HuJun/PycharmProjects/pythonProject/daily_tesy/装饰器带有参数.py
-------1--------
hello world
--------2-----------
ok
Process finished with exit code 0