例如:
>> a = list(["red", "blue", "red"]);
>> b = list(["yellow", "red"]);
array_diff的结果:
>> list("blue")
或最好的方法吗?
答案 0 :(得分:0)
将它们转换为集合并进行集合减法
>>> a = ["red", "blue", "red"]
>>> b = ["yellow", "red"]
>>> set(a) - set(b)
{'blue'}
>>> a
['red', 'blue', 'red'] # the lists are still the same