Bootstrap

2020-06-22

#coding=utf-8

one, two, oF, tF = {}, {}, {}, {} #one, 字符串: 数字 都是唯一数据… oF 相反

list1, list2 = [], [] # 循环的数据 可以重复定义的.

oneStr, oneInt, twoStr, twoInt = [], [], [], []
obj = {} #最终输出数据

fo = open("./1.txt", “r”)
fo2 = open("./2.txt", “r”)

def outDict(str, dict, dF): #定义函数. 将str转换成字典
dict[str.partition("=")[0]] = str.partition("=")[2]
dF[“key” + str.partition("=")[2]] = str.partition("=")[0] # + key 区分 字典中key值是 是数字的问题. 在最终输出时 以去除
# print(str, str.partition("=")[2])
# print(dict)

for line in fo.readlines():
outDict(line.strip(), one, oF)

for line in fo2.readlines():
outDict(line.strip(), two, tF)

oneStr = one.keys() #key值 数组

oneInt = one.values() #value值 数组

oneInt = map(lambda x: ‘key’ + x, one.values()) #value值 数组
twoStr = two.keys() #key值 数组

twoInt = two.values() #value值 数组

twoInt = map(lambda x: ‘key’ + x, two.values()) #value值 数组
print oF
print tF

print one

print two

已one数据为主循环数据

for item in oneStr:
if item in twoStr:
if one[item] != two[item]:
obj[item] = one[item] + " " + two[item]

for item in oneInt:
if item in twoInt:
if oF[item] != tF[item]:
obj[oF[item] + " " + tF[item]] = item

for item in obj:
obj[item] = obj[item].replace(“key”, “”) # + key 区分 字典中key值是 是数字的问题. 在最终输出时 以去除

print obj

with open("./out.txt", ‘w’) as file_obj:
for l in obj:
file_obj.write(l + " " + obj[l] + “\n”)

;