file1='C:/Users/mrco/Desktop/对比/bbdops.com.txt'
file2='C:/Users/mrco/Desktop/对比/tableExport.txt'
 
list = {}
 
with open(file1,'r',encoding='utf-8') as f:
  for lines in f.readlines():
    k = lines.split()[0].strip()
    v = lines.split()[1].strip()
    list[k] = v
 
with open(file2,'r',encoding='utf-8') as f1:
  for lines in f1.readlines():
    k1 = lines.split()[0].strip()
    v1 = lines.split()[1].strip()
    if k1 in list.keys():
      if list[k1] == v1:
        pass
      else:
        list[k1] = list[k1] + '/' + v1
    else:
      list[k1] = v1
 
for k, v in list.items():
    print(k, '\t', v)
  • python/dns-diff.py.txt
  • 最后更改: 2019/04/16 18:31
  • (外部编辑)