a = {'a', 'b', 'c'}
b = {'d', 'e', 'f'}
我想添加以上两个设定值.我需要像
I want to add above two set values. I need output like
c = {'a', 'b', 'c', 'd', 'e', 'f'}
你所要做的就是把它们结合起来
All you have to do to combine them is
c = a | b
集合是唯一值的无序序列.<代码>一个 |b 或 a.union(b)
是两个集合的并集(一个包含在任一集合中找到的所有值的新集合).这是一类称为设置操作"的操作,Python set
s 为提供方便的工具.
Sets are unordered sequences of unique values. a | b
or a.union(b)
is the union of the two sets (a new set with all values found in either set). This is a class of operation called a "set operation", which Python set
s provide convenient tools for.
这篇关于如何添加两组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!