Python path Day10 function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.