使用集合(set)的交集操作
可以将两个列表转换为集合,然后使用集合的intersection()方法或&运算符来获取交集。例如,set(list1).intersection(set(list2))或set(list1) & set(list2)都能返回两个列表的交集。