配置比对脚本(python)
# -*- 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)的更多相关文章
- Gitlab-CI持续集成之Runner配置和CI脚本
p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...
- gitlab6 nginx配置和启动脚本
gitlab6 nginx配置和启动脚本 cheungmine 2013-10 最近把gitlab安装到了ubuntu12.04.3的虚拟机上了.参考: https://github.com/gitl ...
- Centos 配置开机启动脚本启动 docker 容器
Centos 配置开机启动脚本启动 docker 容器 Intro 我们的 Centos 服务器上部署了好多个 docker 容器,因故重启的时候就会导致还得手动去手动重启这些 docker 容器,为 ...
- 配置豆瓣镜像作为python 库的下载源
配置豆瓣镜像作为python 库的下载源 Windows 下如下配置:
- 配置基于Vim的Python开发环境
配置基于Vim的Python开发环境插件 Vundle YouCompleteMe NERDTree Vim-Jinja2-Syntax set nocompatible " be iMpr ...
- 【转】jenkins上配置robotframeworkride自动化脚本任务
jenkins上配置robotframeworkride自动化脚本任务 编写好的自动化脚本,集成在jenkins上进行自动运行于监控,这里采用分布式构建,在一台slave上进行任务构建与自动化脚本的运 ...
- ubuntu系统自动配置开机启动脚本
以前一直搞的centos配置开机启动脚本,但是相同方法用在ubuntu系统上就不管用了,非常伤脑筋. 非常感谢 https://www.linuxidc.com/Linux/2017-09/1471 ...
- 批量修改Linux密码脚本(Python)
搭建环境 centos 7.4 使用脚本 python 批量修改connect用户的密码 生成密码为随机密码 保存为xls文档 #!/usr/bin/env python # -*- coding: ...
- 配置Office Excel运行Python宏脚本
基本环境 名称 版本 操作系统 Windows 10 x64 Office 2016 安装Python 1.下载Python安装包 登录https://www.python.org/downloads ...
随机推荐
- Z字形扫描(201412-2)
问题描述 在图像编码的算法中,需要将一个给定的方形矩阵进行Z字形扫描(Zigzag Scan).给定一个n×n的矩阵,Z字形扫描的过程如下图所示: 对于下面的4×4的矩阵, 1 5 3 9 3 7 5 ...
- 【转载】在IT界取得成功应该知道的10件事
在IT界取得成功应该知道的10件事 2011-08-11 13:31:30 分类: 项目管理 导读:前面大多数文章都是Jack Wallen写的,这是他的新作,看来要成为NB程序员还要不停的自我总结 ...
- Android源代码查看途径
作为一个android coder,多阅读android源码对提高android开发水平是很有帮助的,那么我们可以通过哪些途径查看android源码呢 1.如果你能够FQ的话可以去android官网查 ...
- SVN搭建简单教程
一.引言 笔者曾经试图在网上搜索一篇关于SVN源代码服务器搭建方面的中文技术文章,可惜,所找到的,要么是不完整,要么就是对笔者没什么帮助的文章,TortoiseSvn的帮助文档固然强大,但因为是英文, ...
- 导出excel报错
System.ComponentModel.Win32Exception: 拒绝访问 1.问题现象: foreach (System.Diagnostics.Process thispro in Sy ...
- mac 下设置jdk 路径,设置hadoop 路径
1. touch ~/.bash_profile 创建一个文件 2.vim ~/.bash_profile JAVA_HOME=/Library/Java/JavaVirtualMachines/j ...
- angularjs $scope.$watch(),监听值得变化
myApp.controller('firstController',function($scope,$interval){ $scope.date = new Date(); setInterval ...
- 取两个String数组的交集
import org.testng.annotations.Test; import java.util.HashMap; import java.util.LinkedList; import ja ...
- Qt - 读取GPS数据
1.GPS型号为ublox(EVK-M8L),配有USB接口,Qt版本5.7 2.实现步骤: (1)实现串口通信 采用Qt5.7 内置的串口操作类QSerialPort和QSerialPortInfo ...
- IE浏览器版本判断 HTML代码
<!--[if IE 6.0]> <div id="noie6" style="z-index: 20002;border: 1px solid #F7 ...