网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

在python 中怎样取两个集合的并集

时间:2024-10-12 08:00:24

1、首先是打开python的编辑器

在python 中怎样取两个集合的并集

3、新建第一个集合list1list1={1,3,5,9}

在python 中怎样取两个集合的并集

5、利用union函数得出并集

在python 中怎样取两个集合的并集

7、最后运行这个程序。完整代码如下:l坡纠课柩ist1={1,3,5,9}list2={4,3,10,12}bingji=list1.union(list2)print(bingji)

在python 中怎样取两个集合的并集
© 一点资料