【发布时间】:2023-01-26 01:09:14
【问题描述】:
我有两个元组列表,如果 list2 中元组的前两个元素与 list1 中元组的前两个元素匹配,我想从 list1 中删除所有元组。
list1 = [('google', 'data', '1'), ('google', 'data', '2'), ('google', 'data', '3'), ('google', 'data', '4'), ('google', 'WORLD', '1')]
list2 = [('google', 'data', '1'), ('google', 'HELLO', '2'), ('google', 'BLA', '3')]
结果:
list1 = [('google', 'WORLD', '1')]
【问题讨论】:
-
尝试并提供minimal reproducible example如果你有问题
标签: python list tuples element