参考链接: Python Set union()
两个给定集合的并集是包含两个集合的所有元素的最小集合。...用法:
set1.union(set2, set3, set4….)
...union of all sets(set1, set2, set3…) with set1.
...以下是上述方法的Python3实现:
# Python3 program for union() function
set1 = {2, 4, 5, 6}
set2 = {4, 6, 7, 8}... set3 = {7, 8, 9, 10}
# union of two sets
print("set1 U set2:", set1.union(set2))
# union of three