欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python中l(wèi)ogging模塊的用法實(shí)例

 更新時(shí)間:2014年09月29日 10:24:00   投稿:shichen2014  
這篇文章主要介紹了Python中l(wèi)ogging模塊的用法實(shí)例,以實(shí)例形式介紹了日志模塊logging的用法,具有一定的實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了logging模塊的用法實(shí)例,分享給大家供大家參考。具體方法如下:

import logging 
import os 
 
log = logging.getLogger() 
formatter = logging.Formatter('[%(asctime)s] [%(name)s] %(levelname)s: %(message)s') 
 
 
stream_handler = logging.StreamHandler() 
file_handler = logging.FileHandler(os.path.join("c:\\", "analysis.log")) 
 
 
file_handler.setFormatter(formatter) 
stream_handler.setFormatter(formatter) 
 
 
log.addHandler(file_handler) 
log.addHandler(stream_handler) 
log.setLevel(logging.DEBUG) 
 
 
log.warn("a warning %s " % "c:\\") 

程序運(yùn)行結(jié)果如下:

[2014-09-29 10:23:58,905] [root] WARNING: a warning c:\

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論