我有两个这样的列表
found = ['CG', 'E6', 'E1', 'E2', 'E4', 'L2', 'E7', 'E5', 'L1', 'E2BS', 'E2BS', 'E2BS', 'E2', 'E1^E4', 'E5']
expected = ['E1', 'E2', 'E4', 'E1^E4', 'E6', 'E7', 'L1', 'L2', 'CG', 'E2BS', 'E3']
我想找出两个列表之间的差异。
我已经做好了
list(set(expected)-set(found))
和
list(set(found)-set(expected))
分别返回['E3']
和['E5']
。
但是,我需要的答案是:
'E3' is missing from found.
'E5' is missing from expected.
There are 2 copies of 'E5' in found.
There are 3 copies of 'E2BS' in found.
There are 2 copies of 'E2' in found.
欢迎任何帮助/建议!