my_set = {1, 2, 3}
my_set.add(4)
print(my_set) # Output: {1, 2, 3, 4}
my_set = {1, 2, 3}
my_set.remove(2)
print(my_set) # Output: {1, 3}
my_set = {1, 2, 3}
my_set.clear()
print(my_set) # Output: set()
set1 = {1, 2, 3}
set2 = {2, 3, 4}
intersection_set = set1.intersection(set2)
print(intersection_set) # Output: {2, 3}
set1 = {1, 2, 3}
set2 = {2, 3, 4}
union_set = set1.union(set2)
print(union_set) # Output: {1, 2, 3, 4}
set1 = {1, 2, 3}
set2 = {2, 3, 4}
difference_set = set1.difference(set2)
print(difference_set) # Output: {1}
這些是set常用的操作,還有其他一些操作可以參考Python官方文檔。