Chinaunix
标题:
常用的函数集
[打印本页]
作者:
pybull
时间:
2009-09-25 16:18
标题:
常用的函数集
#获取父目录def getParentPath():
import os
dirList = os.getcwd().split('/')
if dirList == 2:
return '/'
else:
dirList.pop()
return '/'.join(dirList)
#返回日志对象,并在凌晨轮转日志def appLog(logFile):
import logging
from logging.handlers import TimedRotatingFileHandler
formatter = logging.Formatter("[%(asctime)s] {%(levelname)s} %(message)s")
logger = logging.getLogger()
handler = TimedRotatingFileHandler(logFile, 'midnight', 1, 0)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
return logger
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u3/103148/showart_2060010.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2