1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message') logging.info('This is info message') logging.warning('This is warning message') 屏幕上打印:WARNING:root:This is warning message 默认情况下,logging将日志打印到屏幕,日志级别为WARNING:日志级别大小关系为:CRITICAL > ERR…
import logging # 简单打印日志举例 logging.basicConfig(level=logging.DEBUG) # 设置日志级别,WARN logging.warning('Watch out!') # will print a message to the console logging.info('I told you so') # will not print anything # 打印日志到文件,注意要新起一个文件,否则不能保存文件 def log_to_file(…
1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message')logging.info('This is info message')logging.warning('This is warning message') 屏幕上打印:WARNING:root:This is warning message 默认情况下,logging将日志打印到屏幕,日志级别为WARNING:日志级别大小关系为:CRITICAL > ERROR…