我有一个带有 (string,int) 对的元组列表。
我也有一个 int 的列表。
我想通过以下伪代码过滤元组列表:
l1 = list of touples(string,int)
l2 = list of int's
for tuple in l1:
if tuple(int) is in l2
remove tuple from l1
Run Code Online (Sandbox Code Playgroud)
例如,让我们说
l1=[("one",1),("two",5),("three",8),("bla",11)]
l2=[1,8]
Run Code Online (Sandbox Code Playgroud)
输出将是:
[("two",5),("bla",11)]
Run Code Online (Sandbox Code Playgroud)
希望这很清楚。