首页
学习
活动
专区
工具
TVP
发布

python3

专栏作者
11919
文章
14141955
阅读量
238
订阅数
Python 日志(Log)
eg_2 import logging LOG_FORMAT = "%(asctime)s=====%(levelname)s++++++%(message)s" logging.basicConfig(filename="eg_1.log", level=logging.DEBUG, format=LOG_FORMAT) logging.debug("This is a debug log.") # 参数msg logging.info("This is a info log.") logging.warning("This is a warning log.") logging.error("This is a error log.") logging.critical("This is a critical log.") ''' eg_1.log: 2018-08-28 21:31:35,269=====DEBUG++++++This is a debug log. 2018-08-28 21:31:35,271=====INFO++++++This is a info log. 2018-08-28 21:31:35,271=====WARNING++++++This is a warning log. 2018-08-28 21:31:35,271=====ERROR++++++This is a error log. 2018-08-28 21:31:35,271=====CRITICAL++++++This is a critical log. 2018-08-28 21:31:57,768=====DEBUG++++++This is a debug log. 2018-08-28 21:31:57,776=====INFO++++++This is a info log. 2018-08-28 21:31:57,776=====WARNING++++++This is a warning log. 2018-08-28 21:31:57,777=====ERROR++++++This is a error log. 2018-08-28 21:31:57,777=====CRITICAL++++++This is a critical log. ''' format当然是有很多参数的喵~用时自查 四大组件
py3study
2020-01-19
7090
loggin(日志模块)
普通情况下,在控制台显示输出 print() 报告正常程序操作过程中发生的事件 logging.info()(或者更详细的logging.debug()) 发出有关特定事件的警告 warnings.warn()或者logging.warning() 报告错误 弹出异常 在不引发异常的情况下报告错误 logging.error(), logging.exception()或者logging.critical()
py3study
2020-01-17
6690
#7 Python代码调试
Python已经学了这么久了,你现在已经长大了,该学会自己调试代码了!相信大家在编写程序过程中会遇到大量的错误信息,我也不例外的啦~遇到这些问题该怎么解决呢?使用最多的方法就是使用print打印中间变量了哇,关于这种方法怎么说呢~low!!!这一节将记录Python中一项很重要的技能:Debug(代码调试),Here We Go!
py3study
2020-01-16
5490
python ftplib模块
Python中默认安装的ftplib模块定义了FTP类,其中函数有限,可用来实现简单的ftp客户端,用于上传或下载文件
py3study
2020-01-15
7690
python 编写管理redmine的相
最近公司在使用redmine来管理项目,为了便利维护,用python写了两个小程序,和大家分享一下
py3study
2020-01-15
8520
python按月分表
import time from datetime import datetime import calendar import MySQLdb import sys
py3study
2020-01-13
7500
3Mysql 的常用操作
root@OBird ~]# mysql -uroot -pzaq12wsx   #入库
py3study
2020-01-13
3940
python logging简单使用
#coding: UTF-8 ''' Created on 2014年1月6日 @author: mingliu ''' import logging#导入 mylog = logging.getLogger('mylogger')#申请一个名字 otherlog = logging.getLogger('mylogger')#同一个工程下面全部logger全可以统一根据名字获得,享用相同配置 mylog.setLevel(logging.ERROR)#设置输出级别 fh = logging.FileHandler('test.log')#设置输出信息物理位置(文件) fh.setLevel(logging.DEBUG)#设置handler输出级别 ch = logging.StreamHandler()#设置输出控制台 ch.setLevel(logging.INFO) formatter = logging.Formatter("%(pathname)s-%(module)s - \ %(lineno)d -%(asctime)s - %(name)s - %(levelname)s-%(levelno)s-%(thread)d\n%(message)s")#输出信息格式 fh.setFormatter(formatter)  #向handler添加输出格式 ch.setFormatter(formatter)   mylog.addHandler(fh)#向logger添加handler mylog.addHandler(ch) if __name__ == '__main__':    pass    mylog.debug('testDebug')    mylog.info('testInfo')    mylog.warn('testWarn')    mylog.error('testError')    otherlog.debug('testDebug')    otherlog.info('testInfo')    otherlog.warn('testWarn')    otherlog.error('testError')
py3study
2020-01-10
3310
Rails 3 Script/ 改版
相信如果之前用过 2.* rails 的人都知道. 我们习惯用 ./script/generate [xxxx] 或者 ./script/* [xxxx].
py3study
2020-01-10
7.1K0
Python——域名解析成IP地址
一.说明 Python的Socket模块提供有域名转为对应IP地址的方法。本例中,将urllist.txt中的每行URL都试图解析成IP地址,保存到iplist.txt。需要注的是,socket.gethostbyname(url)方法中的url参数不能带有“http”这样的协议前缀,否则不能解析成IP地址。为了对比解析效果,加入了两条错误的域名格式,以便引起读者注意。
py3study
2020-01-09
13.9K0
Python logging模块
logging模块是Python的一个标准库模块,开发过程中,可以通过该模块,灵活的完成日志的记录。
py3study
2020-01-09
4030
六、CPU优化(3)处理器组
(1)“-d”参数。标识master.mdf文件的位置。一般为C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\master.mdf 。
py3study
2020-01-09
9570
python实现的简版iconv
系统管理中,经常涉及的文件编码就是UTF8和GB1803,下面是实现iconv简化功能(UTF8,GB18030互转)的python代码:
py3study
2020-01-09
1.8K0
入侵渗透专用的python小脚本
渗透的很多时候,在网上找到的工具并不适用,自己写代码才是王道,下面三个程序都是渗透时在网络上找不到合适工具,自己辛苦开发的红黑联盟,短小使用,求欣赏,求好评。
py3study
2020-01-06
8700
python日志处理模块
一 日志处理模块概述 1 日志级别 日志级别level 数值 CRITICAL 50 ERROR 40 WARNING 30 ,默认日志级别 INFO 20 DEBUG 10 NOTSET 0,表示不设置 日志级别是指产生日志的严重程度 设置一个级别后,严重程度低于次级别的日志消息将会被忽略 数字越高,优先级别越高 #!/usr/bin/python3.6 #conding:utf-8 import threading import time import logging logging.ba
py3study
2020-01-03
5840
python 日志记录
#!/bin/env python #--*-- coding=utf8 --*-- # # Author: ablozhou # E-mail: ablozhou@gmail.com # # Copyright 2010 ablozhou # # Distributed under the terms of the GPL (GNU Public License) # # hzdq is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # 2010.3.14 写文件,log级别常数定义 import datetime import sys import traceback import codecs import types #log编码全部按utf8处理 loglevels = {'stdout':['info','debug','warn','error','fatal'], 'file':['info','debug','warn','error','fatal'] } logfile = 'logs.txt' class log4py: def __init__(self,modulename='gloabal', loglevel=loglevels, filename='log4py.txt'): self.filename = filename #self.flag = set(loglevel['stdout']+loglevel['file']) self.loglevel = loglevel self.modulename = modulename self.fcname = None class function(): def __init__(self,fcname,parent): parent.debug('enter ',fcname) self.fcname = fcname self.parent = parent def __del__(self): self.parent.debug('exit ',self.fcname) def dbgfc(self,fcname): '''set debug function name''' f = None if 'debug' in self.flag: f = self.function(fcname,self) return f def _gettime(self): return datetime.datetime.now().isoformat() def outstd(self,*fmt): s = self.fmtstr(*fmt) print s def outfile
py3study
2020-01-03
8610
没有更多了
社区活动
RAG七天入门训练营
鹅厂大牛手把手带你上手实战
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档