如何在Python中比较一个列表的列表/集合?

10 浏览
0 Comments

如何在Python中比较一个列表的列表/集合?

最简单的方法是如何比较这两个列表/集合并输出差异?有没有内置函数可以帮助我比较嵌套的列表/集合?

输入:

First_list = [['Test.doc', '1a1a1a', 1111], 
              ['Test2.doc', '2b2b2b', 2222],  
              ['Test3.doc', '3c3c3c', 3333]
             ]  
Secnd_list = [['Test.doc', '1a1a1a', 1111], 
              ['Test2.doc', '2b2b2b', 2222], 
              ['Test3.doc', '8p8p8p', 9999], 
              ['Test4.doc', '4d4d4d', 4444]]  

期望输出:

Differences = [['Test3.doc', '3c3c3c', 3333],
               ['Test3.doc', '8p8p8p', 9999], 
               ['Test4.doc', '4d4d4d', 4444]]

0