1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| names1 = {"Aaron", "Tony", "Bob", "Wang"} names2 = {"Tony","Bob", "Cat"} names3 = {"Amy", "Tony"}
print("names1、names2、name3 的并集:", names1.union(names2, names3))
print("names1、names2、name3 的并集:", names1 | names2 | names3)
names1.update(names2, names3) print("After updpate, names1 : ", names1) print("After updpate, names2 : ", names2) print("After updpate, names3 : ", names3) names1 = {"Aaron", "Tony", "Bob", "Wang"} names2 = {"Tony","Bob", "Cat"}
names1 |= names2 print("After |=, names1 : ", names1) print("After |=, names2 : ", names2)
|