import logging logging.basicConfig(level=logging.INFO, filename=‘mylog.log‘) logging.info(‘Starting program‘) logging.info(‘Trying to divide 1 by 0‘) print 1 / 0 logging.info(‘The division succeeded‘) logging.info(‘Ending program‘)
在python中使用logging模块
时间: 2024-10-18 03:47:05