# -*- coding: utf- -*-
from datetime import *
import MySQLdb
import sys
import time
import datetime
import json
import logging

logging.basicConfig(level=logging.INFO,
                format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                datefmt='%a, %d %b %Y %H:%M:%S',
                filename='tb_test004.log',
                filemode='w')

console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)

def process():
    dict1 = {}
    file1 = open("newlogic52.txt")
    :
        line = file1.readline()
        if not line:
           break
        arr_line = line.split( );
        :
            #logging.info(arr_line[])
            #logging.info(arr_line[])
            key = arr_line[]
            value = arr_line[]
            dict1[key] = value
        else:
            continue

    logging.info("-------------------------")

    dict2 = {}
    file2 = open("oldlogic52.txt")
    :
        line = file2.readline()
        if not line:
           break
        arr_line = line.split( );
        :
            #logging.info(arr_line[])
            #logging.info(arr_line[])
            key = arr_line[]
            value = arr_line[]
            dict2[key] = value
        else:
            continue

    f = file("hello3.txt","w+")
    logging.info("************************")
    sume =
    for key1 in dict1:
        #logging.info(key1)
        #logging.info(dict1[key1])
        for key2 in dict2:
            # logging.info(key2)
            # logging.info(dict2[key2])
            if key1.strip() == key2.strip() and dict1[key1].strip() != dict2[key2].strip():
                li1 = "new key:%s , value: %s \n" % (key1,dict1[key1])
                #logging.info(li1)
                li2 = "old key:%s , value: %s \n" % (key2,dict2[key2])
                #logging.info(li2)

            if key1.strip() == key2.strip() and dict1[key1].strip() == dict2[key2].strip():
                sume = sume +
            if key1.strip() == key2.strip() and dict1[key1].strip() == dict2[key2].strip():
                li1 = "%s=%s\n" % (key1.strip(),dict1[key1].strip())
                f.writelines(li1)
    f.close()

    dict3 = {}
    file3 = open("hello3.txt")
    :
        line = file3.readline()
        if not line:
           break
        arr_line = line.split( );
        :
            #logging.info(arr_line[])
            #logging.info(arr_line[])
            key = arr_line[]
            value = arr_line[]
            dict3[key] = value
        else:
            continue

    for key2 in dict2:
        # logging.info(key2)
        # logging.info(dict3[key2])
        if dict3[key2] == None:
            logging.info(key2)

    logging.info("@@@@@@@@@@@@@@@@@@@@@@@@@@")
    logging.info(sume)
    logging.info("new %s" % len(dict1))
    logging.info("old %s" % len(dict2))
    logging.info("same %s" % len(dict3))

if __name__ == "__main__":
   process()

配置比对脚本(python)的更多相关文章

  1. Gitlab-CI持续集成之Runner配置和CI脚本

    p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...

  2. gitlab6 nginx配置和启动脚本

    gitlab6 nginx配置和启动脚本 cheungmine 2013-10 最近把gitlab安装到了ubuntu12.04.3的虚拟机上了.参考: https://github.com/gitl ...

  3. Centos 配置开机启动脚本启动 docker 容器

    Centos 配置开机启动脚本启动 docker 容器 Intro 我们的 Centos 服务器上部署了好多个 docker 容器,因故重启的时候就会导致还得手动去手动重启这些 docker 容器,为 ...

  4. 配置豆瓣镜像作为python 库的下载源

    配置豆瓣镜像作为python 库的下载源 Windows 下如下配置:

  5. 配置基于Vim的Python开发环境

    配置基于Vim的Python开发环境插件 Vundle YouCompleteMe NERDTree Vim-Jinja2-Syntax set nocompatible " be iMpr ...

  6. 【转】jenkins上配置robotframeworkride自动化脚本任务

    jenkins上配置robotframeworkride自动化脚本任务 编写好的自动化脚本,集成在jenkins上进行自动运行于监控,这里采用分布式构建,在一台slave上进行任务构建与自动化脚本的运 ...

  7. ubuntu系统自动配置开机启动脚本

    以前一直搞的centos配置开机启动脚本,但是相同方法用在ubuntu系统上就不管用了,非常伤脑筋. 非常感谢  https://www.linuxidc.com/Linux/2017-09/1471 ...

  8. 批量修改Linux密码脚本(Python)

    搭建环境 centos 7.4 使用脚本 python 批量修改connect用户的密码 生成密码为随机密码 保存为xls文档 #!/usr/bin/env python # -*- coding: ...

  9. 配置Office Excel运行Python宏脚本

    基本环境 名称 版本 操作系统 Windows 10 x64 Office 2016 安装Python 1.下载Python安装包 登录https://www.python.org/downloads ...

随机推荐

  1. 按日期切割nginx访问日志--及性能优化

    先谈下我们需求,一个比较大的nginx访问日志,根据访问日期切割日志,保存在/tmp目录下. 测试机器为腾讯云机子,单核1G内存.测试日志大小80M. 不使用多线程版: #!/usr/bin/env ...

  2. MySQL查看已安装的编译参数

    MySQL5.1.x版本 cat $path/bin/mysqlbug|grep configure MySQL5.5.x

  3. MYSQL、PHP基础、面向对象基础简单复习总结

    一.MYSQL         1.配置MySql                 第一步安装服务器(apache).                 第二部安装MySql界面程序         2 ...

  4. 分享公司DAO层数据库结果映射到对象的方法

    主题 前面写过一篇文章,分享了公司是怎么动态封装SQL查询条件的(http://www.cnblogs.com/abcwt112/p/5874401.html). 里面提到数据库查询结果二维数组最后是 ...

  5. VBA学习思路

    打算花两三天学习VBA的基础,学习资料为<别怕,VBA其实很简单>,为了快速学习,先了解大致框架,后续再深入学习各种属性.方法和技巧. 1.VBA编程环境基本操作,手工操作,熟悉即可 2. ...

  6. 每天写点shell--命令行参数

    1.读取参数:位置参数变量是标准的数字: $0是程序名, $1是第一个参数, $2是第二个参数... #!/bin/bash # using one command line parameter fa ...

  7. ORACLE_UNQNAME

    之前在自己笔记本win7系统上安装了oracle 11g,当时为了节省资源,没启用EM. 此时查看EM状态: C:\Windows\system32>emctl status dbconsole ...

  8. pycharm 2016.3 注册码

    Choose Active Code 43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYX ...

  9. mysql使用load导入csv文件所遇到的问题及解决方法

    使用navicat的客户端插入csv的数据文件,有一种非常简单的方式,即使用导入向导,直接根据数据匹配即可. 使用load的方式. 由于本项目中插入数据表量大而且格式统一,故首先使用创建字段creat ...

  10. Sublime text 3如何编辑less并转(编译)成css文件

    今天开始学习使用less这个强大方便的前端工具,本来是考虑用koala(专门编辑less的软件)来使用less的,但是发现sublime编辑器也可以实现对less的编译及高亮显示代码,这样既能少用一个 ...