aset = {
1, 2, 3}
aset.update() # It is OK not to pass parameters , Return as is
print(aset) # {1, 2, 3}
aset.update({
4, 5}) # Merge sets
print(aset) # {1, 2, 3, 4, 5}
aset.update({
6, 7}, {
8, 9}) # Merge multiple sets at once , The following types can be multiple as long as they can be merged , And different types can be mixed
print(aset) # {1, 2, 3, 4, 5, 6, 7, 8, 9}
aset.update({
'a': 10}) # Updating the dictionary only takes keys
print(aset) # {1, 2, 3, 4, 5, 6, 7, 8, 9, 'a'}
bset={
'b','c'}
bset.update(['d']) # Update with list ( The same is true for tuples )
print(bset) # {'b', 'c', 'd'}
bset.update('ef1') # Update with string
print(bset) # {'b', 'c', 'd', 'e', 'f', '1'}
bset.update(2) # But individual numbers don't work ,update The needs passed in are iteratable objects
print(bset) # TypeError