import logging, os
appPath = os.path.dirname(os.path.abspath(__file__))
def main():
pass
errorLogPath = appPath + '//myappErrorLog.log'
logging.basicConfig(
level=logging.DEBUG,
filename = errorLogPath,
filemode='w+',
format= '%(asctime)s - %(levelname)s - %(message)s'
)
try:
main()
os.remove(errorLogPath) #error
except:
logging.exception("myapp:")
文件未在Windows平台上删除(unix normal),错误 - WindowsError:[错误32]进程无法访问该文件。
如何使用模块记录关闭和删除文件?