One: The depth copy: s = [[], 3, 4] S1 = S.copy (), s1[0][0] = 8, print (s), print (S1), two results are [[8,1], 3, 4] The first is because the list can be modified, and then a pointer has a relationship, the figure is as follows:
A shallow copy (shallow copy) copies only the first layer, such as the 3,4 above, because only one pointer is pointing to the
Deep copy: All clones require modules, import copy
Two: Set set: Combine different elements together, only one way to create, S = Set (' Fanxi ') print (s) s = {' F ', ' a ', ' n ', ' x ', ' I '}. can go heavy. s = [' 11 ', ' 22 '. ' 333 ' One ' print s prints out is the set {}, which is cast to list.
The elements in the set must be hashed, immutable, such as strings, shapes, keys, and tuples, but the list cannot be. The elements that come out are unordered and can be taken later with a for loop or iterator. Use in or not to determine if it is inside
Set is a mutable set, and there are immutable sets (Frozenset)
Three. Updates for mutable collections. S.add (' SS ') adds an element. S.update (' CCC ') ' C ', ' C ', ' C ' is printed like this. S.update (["Eee]") is also added. S.remove ()
Four, subset superset, is the mathematical relationship, print (' AAA ' or set (' AAA ')): Two randomly take one print. No, I tried it myself a couple of times, the same, different. Here is a bit of a confused, very chaotic, and later met to explore it carefully.
Intersection the intersection of the Union. Difference set: Print (A.differrence (b)) A and B does not.
Python path Day10 function