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模块,布布扣,bubuko.com
原文地址:http://gomic.blog.51cto.com/8689134/1539036