python中怎样取两个交集的集合

2024-10-28 22:54:34

1、首先是打开pycharm编辑器。

python中怎样取两个交集的集合

3、新建第一个集合list1

python中怎样取两个交集的集合

5、然后通过intersection函数将两个集合的交集取出来。

python中怎样取两个交集的集合

7、运行该程序,完整代码如下:list1={1,2,5,9}list2={1,8,9}print(list1.intersection(list2))

python中怎样取两个交集的集合
猜你喜欢