1、log 文件的操作
import logging def log(log_content): # 定义文件 logFile = logging.FileHandler('logInfo.md','a',encoding='utf-8') # log 格式 fmt = logging.Formatter(fmt='%(asctime)s-%(levelname)s-%(module)s:%(message)s') logFile.setFormatter(fmt) # 定义日志 logger1 = logging.Logger('logTest', level=logging.DEBUG) logger1.addHandler(logFile) logger1.info(log_content) log('hello world')