本文实例讲述了python实现写日志封装类。分享给大家供大家参考。具体如下: # encoding:utf-8 import sys import logging import time def writeLog(message): logger=logging.getLogger() filename = time.strftime('%Y-%m-%d',time.localtime(time.time())) handler=logging.FileHandler("./log/"+filename+"error") logger.addHandler(handler)