标签:this set err level conf eve log win10 org
拒绝print,使用 logging !
#https://docs.python.org/3.5/howto/logging.html?highlight=logging
#win10 + python 3.5.2
import logging
#default level : WARNING #30
#CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET
logging.debug(‘debug message‘)
logging.info(‘info message‘)
logging.warning(‘warning message‘)
>>> [log.CRITICAL ,log.ERROR, log.WARNING,log.INFO,log.DEBUG,log.NOTSET]
[50, 40, 30, 20, 10, 0]
>>> log.getLevelName(logger.getEffectiveLevel())
‘WARNING‘
import logging
logging.basicConfig(filename=‘example.log‘,level=logging.DEBUG)
logging.debug(‘This message should go to the log file‘)
logging.info(‘So should this‘)
logging.warning(‘And this, too‘)
标签:this set err level conf eve log win10 org
原文地址:http://www.cnblogs.com/squirrel2300/p/6697133.html