日志文件
import logging
import logging.handlers
class Log:
def __init__(self):
FILENAME='LOG'
logging.basicConfig(level=logging.INFO)
root_logger = logging.getLogger('')
logger = logging.handlers.TimedRotatingFileHandler(FILENAME,'midnight',1)
root_logger.addHandler(logger)
logging.getLogger('log')
主文件
from Log import Log
import time
import logging
log_obj = Log()
log = logging.getLogger('log')
log.info("Service Started")
while 1:
t=1
安装程序.py
from cx_Freeze import setup, Executable
setup(
name = "Test",
version = "0.1",
description = "Test",
executables = [Executable("Main.py", base="Win32GUI")])
所以这是我正在使用的最终代码。EXE 文件已创建,但运行时出现错误。错误是“Nonetype 对象没有属性类型‘write’”
等你回复。