# -*- 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. http执行过程分析

    执行过程: 1.用户在浏览器(客户端)里输入或者点击一个网址链接: 2.浏览器通过网址域名查找ip地址.DNS查找方式是通过浏览器缓存(会记录DNS记录)→系统缓存→TCP/IP参数中设置的首选DNS ...

  2. 【ASP.NET程序员福利】打造一款人见人爱的ORM(二)

    上一篇我已经给大家介绍AntORM的框架[ASP.NET程序员福利]打造一款人见人爱的ORM(一),今天就来着重介绍一下如何使用这套框架 1>AntORM 所有成员 如果你只想操作一种数据库,可 ...

  3. 常用的数据统计Sql 总结

    最近刚在搞一个BI的项目,里面需要大量的sql 数据统计相关运用,加深了我又对SQL的理解与使用. 所以,分享几个数据统计时常用的sql 语句总结: 1. 统计各个条件下的数据 select Batc ...

  4. linux查看MySQL版本的四种方法

    1 在终端下执行 mysql -V 2 在help中查找 mysql --help |grep Distrib 3 在mysql 里查看 select version() 4 在mysql 里查看 s ...

  5. shell脚本学习第一课

    shell是一种程序设计语言,是访问操作系统内核的服务. Linux的shell种类常见的有: Bourne Shell(/usr/bin/sh或/bin/sh) Bourne Again Shell ...

  6. 第4天--linux内核学习

    驱动使用方式1.编译到内核中 * make uImage进入到系统后mknod /dev/led c 500 0 创建设备节点 2.编译为模块 M make module进入到系统后 mknod /d ...

  7. Java上等价类划分测试的实现

    利用JavaFx实现对有效等价类和无效等价类的划分: 代码: import javafx.application.Application;import javafx.event.ActionEvent ...

  8. SQL分页获取数据

    SQL Server分页 select * from (') t Oracle分页 SELECT * FROM (' ORDER BY MaterialNM) t

  9. c#过滤html标签

    public string HtmlFilter(string html)     {         //设置要删除的标记         string[] lable = { "font ...

  10. github添加ssh方法(windows版)

    生成一个新的SSH key 打开 git bash 输入  ssh-keygen -t rsa -b 4096 -C "your_email@example.com" 输入一个文件 ...