# 导入 logging 包
import logging
def decorator(func):
def wrapper(*args,**kwargs):
try:
func(*args,**kwargs)
logging.info(*args,**kwargs)
except:
logging.error(*args,**kwargs)
return wrapper
@decorator
def test(name):
print(1/0)
test('zhangsan')
标签:logging,args,wrapper,decorator,kwargs,装饰,def
From: https://www.cnblogs.com/wangend/p/17321606.html