01:PYTHON中logging模块使用
用于调试代码
import logging
logging.basicConfig(level=logging.INFO)
s = '0'
n = int(s)
logging.info('n = %d' %n)
logging.info("r如果 {}".format(n))
print(10/n)
# level 日志级别,级别不在赘述
logging.info()
logging.warning()
logging.ERROR()
logging.debug()
logging.critical()
配置日志路径
logging.basicConfig(filename=os.path.join(os.getcwd(),'info.log'), filemode= 'a+', level=logging.INFO)
logging.getLogger(os.path.join(os.getcwd(),'info.log')).level=logging.INFO --设置记录那些日志