时间:2021-07-01 10:21:17 帮助过:444人阅读
# 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) logger.setLevel(logging.NOTSET) logger.info(message) if __name__ == '__main__': writeLog("hello")
将这段代码保存为 TLog,调用的时候先import TLog,然后TLog.writelog("jb51.net")即可
希望本文所述对大家的Python程序设计有所帮助。