collection (set)Collection, save a lot of data, can not repeat features: unordered, non-repeatable, content can be hashed, itself is not hash k = f
Rozenset (collection): It's going to be a hash.
Increase:S.add (content) s.update ("content"): Iterative additions
Delete:
S.pop (): Randomly deletes one and returns the deletion of that content s.remove (' specified element '): Delete the specified element, if not present will error S.clear (): Empty collection, if print out empty collection will show set ({})
Modify:It's usually deleted and added.
Check:Use a For loop to query common operations:
intersection:Print (S1 & S2): Returns the same element between them s1.intersection (S2)
and set:
Print (S1 | s2): Returns a collection that includes all of their content, but does not repeat s1.union (S2):
Difference SetPrint (S1-S2) s1.difference (S2): return s1 Remove and S2 have the same content. For example, s1{123},s2{3,4,5} returns {
Depth Copy
Normal CopyS1==S2, if S1 change, S2 will change.
Shallow copy:Just a hash of the surface of the copy, copy the non-hash only copy memory address, so, their list is still variable s2 = s1.copy ()
Deep Copy:Import Copy # Introduction Module LS2 = Copy.deepcopy (1S1) # He's copying everything down, LS1 changes won't affect LS2
Python Full Stack development 07