# Python 集合的交集--intersection函数


### 集合的交集--`intersection函数`

#### 什么是交集

- a , b两个集合分别拥有的`相同`的元素集 , 称为a与b的交集
- ![1](https://cdn.hashnode.com/res/hashnode/image/upload/v1653446675328/NiWktBMie.jpeg)

#### 功能

- 返回**两个或更多集合**中`都包含`的元素,即交集

#### 用法

- `a_set.intersection(b_set...)`

#### 参数

`b_set...`:  与当前集合对比的**1或多个集合**

#### 返回值

- 返回**原始集合**与**对比集合**的`交集`

#### 代码

```python
# coding:utf-8

a = ['dewei', 'xiaomu', 'xiaohua', 'xiaoguo']
b = ['xiaohua', 'dewei', 'xiaoman', 'xiaolin']
c = ['xiaoguang', 'xiaobai', 'dewei', 'xiaoyuan']

a_set = set(a)
b_set = set(b)
c_set = set(c)

print(a_set, b_set, c_set)

result = a_set.intersection(b_set, c_set)
xiaotou = list(result)
print('{} 是 这个小偷'.format(xiaotou[0]))

```


