• Pyhton小工具实现文件对比写入操作


    测试过程中,有新的版本,都要重现填写模板进行CLI 测试,更新模板一行行对比也是很麻烦的事情,而且模板更新很频繁
    开发达蒙写了一个小工具,轻松实现了这个功能,
    2个文件对比,把一样的写进去,多出来的部分你自己填写

    import xml.etree.ElementTree as ET
    import sys


    inputfile = r'C:DevelopmentGitprodataconversionCLI.republish.config'

    outputfile = r'C:DevelopmentGitprodataconversionBuilduildCliDataConvertingCLICLI.republish.config'
    dict = {}
    inputRoot = ET.parse(inputfile).getroot()
    for item in inputRoot.findall('Item'):
    name = item.find('Name')
    value = item.find('Value')
    dict[name.text] = value.text

    print(dict)

    tree = ET.parse(outputfile)
    outputRoot = tree.getroot()
    for item in outputRoot.findall('Item'):
    name = item.find('Name').text
    print(name)
    if name in dict:
    value = item.find('Value')
    print(dict[name])
    value.text = dict[name]

    tree.write(outputfile)
  • 相关阅读:
    PHP学习笔记:第一天自白
    记录ftpclient一下踩的坑
    log4j.xml打印mybatis sql
    ftpclient 550 permission denied
    java内部类demo
    轮播图制作
    java的引用数据类型,你知道吗???
    集合
    Java基础01
    java 自己实现字符串的匹配
  • 原文地址:https://www.cnblogs.com/JacquelineQA/p/14046092.html
Copyright © 2020-2023  润新知