1.logging

 import logging

 #-----------------------------------logging.basicConfig
logging.basicConfig(
level=logging.DEBUG,
filename="logger.log",
filemode="w",
format="%(asctime)s %(filename)s[%(lineno)d] %(message)s" )
#
# logging.debug('hello')
# logging.info('hello')
# logging.warning('warning message')
# logging.error('error message')
# logging.critical('critical message') #-----------------------------------logger
def logger():
logger=logging.getLogger() fh=logging.FileHandler("test_log")
#ch=logging.StreamHandler() fm=logging.Formatter("%(asctime)s %(message)s") fh.setFormatter(fm)
#ch.setFormatter(fm) logger.addHandler(fh)
#logger.addHandler(ch)
logger.setLevel("DEBUG") return logger
# #----------------------
logger=logger() #
# logger.debug("debug")
# logger.info("info")
# logger.warning("warning")
# logger.error("error")
# logger.critical("critical")
#--------------------------------------------------
import logging
#
logger=logging.getLogger() logger1 = logging.getLogger('mylogger')
logger1.setLevel(logging.DEBUG) logger2 = logging.getLogger('mylogger')
logger2.setLevel(logging.WARNING) fh=logging.FileHandler("test_log-new")
ch=logging.StreamHandler() logger.addHandler(ch)
logger.addHandler(fh) logger1.addHandler(fh)
logger1.addHandler(ch) logger2.addHandler(fh)
logger2.addHandler(ch) # logger.debug('logger debug message')
# logger.info('logger info message')
# logger.warning('logger warning message')
# logger.error('logger error message')
# logger.critical('logger critical message') # logger1.debug('logger1 debug message')
# logger1.info('logger1 info message')
# logger1.warning('logger1 warning message')
# logger1.error('logger1 error message')
# logger1.critical('logger1 critical message') logger2.debug('logger2 debug message')
logger2.info('logger2 info message')
logger2.warning('logger2 warning message')
logger2.error('logger2 error message')
logger2.critical('logger2 critical message')

2.configparser

 import configparser

 # config = configparser.ConfigParser()     #config={}
# #
# #
# #
# #
# config["DEFAULT"] = {'ServerAliveInterval': '45',
# 'Compression': 'yes',
# 'CompressionLevel': '9'}
# #
# #
# #
# config['bitbucket.org'] = {}
# config['bitbucket.org']['User'] = 'hg'
# #
# config['topsecret.server.com'] = {}
# topsecret = config['topsecret.server.com']
# topsecret['Host Port'] = '50022' # mutates the parser
# topsecret['ForwardX11'] = 'no' # same here
# #
# #
# #
# with open('example.ini', 'w') as f:
# config.write(f) #------------------------------------------------------增删改查、
import configparser
#
config = configparser.ConfigParser() #---------------------------------------------查
# print(config.sections()) #[] config.read('example.ini')
# #
# print(config.sections()) #['bitbucket.org', 'topsecret.server.com'] # print('bitbucket.org' in config)# False
#
# print(config['bitbucket.org']['User']) # hg
#
# print(config['DEFAULT']['Compression']) #yes
#
# print(config['topsecret.server.com']['ForwardX11']) #no # for key in config['bitbucket.org']:
# print(key) #
#
# print(config.options('bitbucket.org'))#['user', 'serveraliveinterval', 'compression', 'compressionlevel', 'forwardx11']
# print(config.items('bitbucket.org')) #[('serveraliveinterval', '45'), ('compression', 'yes'), ('compressionlevel', '9'), ('forwardx11', 'yes'), ('user', 'hg')]
#
# print(config.get('bitbucket.org','compression'))#yes
#
#
# #---------------------------------------------删,改,增(config.write(open('i.cfg', "w")))
#
#
config.add_section('yuan')
config.set('yuan','k1','')
#
config.remove_section('topsecret.server.com')
config.remove_option('bitbucket.org','user')
# #
#
config.write(open('i.cfg', "w"))

3.md5加密

 # import hashlib

 # obj=hashlib.md5()
#
# obj.update("admin".encode("utf8"))
# print(obj.hexdigest()) #21232f297a57a5a743894a0e4a801fc3 # obj.update("adminroot".encode("utf8"))
# print(obj.hexdigest())# 4b3626865dc6d5cfe1c60b855e68634a
# 4b3626865dc6d5cfe1c60b855e68634a

day23-python之日志 re模块的更多相关文章

  1. python中日志logging模块的性能及多进程详解

    python中日志logging模块的性能及多进程详解 使用Python来写后台任务时,时常需要使用输出日志来记录程序运行的状态,并在发生错误时将错误的详细信息保存下来,以别调试和分析.Python的 ...

  2. [ Python入门教程 ] Python中日志记录模块logging使用实例

    python中的logging模块用于记录日志.用户可以根据程序实现需要自定义日志输出位置.日志级别以及日志格式. 将日志内容输出到屏幕 一个最简单的logging模块使用样例,直接打印显示日志内容到 ...

  3. python 的日志logging模块

    1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message')logging.info('This is info messag ...

  4. python的日志logging模块性能以及多进程

    写在前面: 日志是记录操作的一种好方式.但是日志,基本都是基于文件的,也就是要写到磁盘上的.这时候,磁盘将会成为一个性能瓶颈.对于普通的服务器硬盘(机械磁盘,非固态硬盘),python日志的性能瓶颈是 ...

  5. python 的日志logging模块学习

    1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message') logging.info('This is info messa ...

  6. Python之日志 logging模块

    关于logging模块的日志功能 典型的日志记录的步骤是这样的: 创建logger 创建handler 定义formatter 给handler添加formatter 给logger添加handler ...

  7. Python中日志logging模块

    # coding:utf-8 import logging import os import time class Logger(object): def __init__(self): # 创建一个 ...

  8. python标准日志模块logging及日志系统设计

    最近写一个爬虫系统,需要用到python的日志记录模块,于是便学习了一下. python的标准库里的日志系统从Python2.3开始支持.只要import logging这个模块即可使用.如果你想开发 ...

  9. python标准日志模块logging的使用方法

    参考地址 最近写一个爬虫系统,需要用到python的日志记录模块,于是便学习了一下.python的标准库里的日志系统从Python2.3开始支持.只要import logging这个模块即可使用.如果 ...

  10. 【python】日志系统

    来源: http://blog.csdn.net/wykgf/article/details/11576721 http://www.jb51.net/article/42626.htm http:/ ...

随机推荐

  1. Hadoop 解除 “Name node is in safe mode”(转)

    运行Hadoop程序时,有时候会报以下错误: org.apache.hadoop.dfs.SafeModeException: Cannot delete /user/hadoop/input. Na ...

  2. 牛客网Java刷题知识点之构造函数与set方法、与类名同名的一般方法、构造函数中有return语句

    不多说,直接上干货! 通过 牛客网Java刷题知识点之构造函数是什么.一般函数和构造函数什么区别呢.构造函数的重载.构造函数的内存图解 我们对构造函数有了一个比较清楚的认识,当我们在创建对象时,我们会 ...

  3. ubuntu配置硬盘开机自动挂载

    1.创建/media/fly文件夹 sudo mkdir /home/fly    #根据个人喜好命名 2.获取要自动挂载的分区的UUID和分区类型TYPE sudo blkid 出现如下结果:   ...

  4. Matlab之数据处理

    写在前面的,软件不太强大,每次保存都需要生成rec和dark的文件,在处理是只需要一个就行了,所有网上查看了下运用批处理的命令去掉多余的文件: 解决办法:windows命令模式下CMD进入文件的目录, ...

  5. linux cached过高导致性能变低

    场景: 拿到了客户50个文件,平均每个文件大概40M左右的txt,文件在S3上,需要导入到数据库,40M解析出来大概是80W条左右的数据. 描述: 在刚开始执行导入时,因为数据验证复杂程度不同,每个文 ...

  6. vue-实现一个购物车结算页面

    这是路由之间的跳转,传递值最好采用传参,而不是用$emit和$on,不起作用 如果实在一个页面中的兄弟组件,可以使用$emit和$on 中间件,eventBus.js 放在components目录下面 ...

  7. 使用css写三角箭头

    .right-arrow{ width:6px; height:6px; align-self: center; border-right:1px solid #2ac795; border-left ...

  8. uvm_port_base——TLM1事务级建模方法(五)

    文件: src/tlm1/uvm_port_base.svh 类: uvm_port_base uvm_port_component_base派生自uvm_component,因此具有其所有特性.提供 ...

  9. 绿盟网站安全防护服务(vWAF)

    平台: linux 类型: 虚拟机镜像 软件包: basic software devops nsfocus security waf 服务优惠价: 按服务商许可协议 云服务器费用:查看费用 立即部署 ...

  10. Mysql数据库学习总结(一)

    数据库概念 数据库(Database)是按照数据结构来组织.存储和管理数据,建立在计算机存储设备上的仓库. 简单说,数据库就是存放数据的仓库.和图书馆存放书籍.粮仓存放粮食类似. 数据库分类 分为 关 ...