配置比对脚本(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 ...
随机推荐
- dos 命令帮助文档chm
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
- 【先定一个小目标】Redis 安装成windows服务-开机自启
1.第一步安装成windows服务的,开机自启动 redis-server --service-install redis.windows.conf 2.启动\关闭 redis-server --se ...
- mySql 远程连接(is not allowed to connect to this MySQL server)
如果你想连接你的mysql的时候发生这个错误: ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL serve ...
- MyBatis传入多个参数的问题
一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...
- XF custom render 各平台实现类
目前的XF还是非常简陋的,所以存在大量的自定义工作.一般情况下我们只是要需要派生原生的XF控件,然后在各平台下修改其呈现方法. 所以了解每个XF控件在不同平台上呈现使用的控件类是有所必须要的.以下别人 ...
- 20155217-杨笛-c与java
命是弱者的借口,运是强者的谦词 你有什么技能比大多数人(超过90%以上)更好? 针对这个技能的获取你有什么成功的经验? 与老师博客中的学习经验有什么共同之处? 其实我经常会去想自己有什么拿得出手的优点 ...
- Hadoop基础——第一弹:Hadoop介绍
一.基础 1.了解Java.Linux操作系统相关知识 2.如需精进,应为水平要达到一定标准,能够阅读国外相关技术网站,eg:http://hadoop.apache.org/ 二.什么是Hadoop ...
- Android ActionBar 初探
1.指南,例子,个人感觉 首先上官网指南链接http://developer.android.com/guide/topics/ui/actionbar.html 参考了官网上的例子http://de ...
- rpc-1-OSI模型
rpc-1-OSI模型 第一部分,网络7层协议 1. OSI模型: 开放通信系统互联网参考模型,是国际标准化组织(ISO),提出的一个,试图使各种计算机在世界范围内互连为网络的模式.(遵循这个模式,计 ...
- Android控制ScrollView滚动
有两种办法,第一种,使用scrollTo(),这个方法不需要handler,直接调用就行 第二种方式,使用fullScrol() 下面我们看一下这个函数: scrollView.fullScroll( ...