以下是两个元组列表:
text1_lines = [('a','1'), ('b', '2'), ('c','3')]
text2_lines = [('a','4'), ('z', '5'), ('c','6')]
我可以通过以下代码获得差异
d = difflib.Differ()
diff = d.compare(text1_lines,text2_lines)
diff_list = '\n'.join(diff)
请建议如何将diff_list
转换为列表,以便我可以遍历列表。
答案 0 :(得分:0)
知道了。
d = difflib.Differ()
diff = d.compare(text1_lines,text2_lines)
diff = list(diff)
for item in diff:
print(item)