The road to wudao-the three major days of the refining stage

Source: Internet
Author: User

The road to wudao-the three major days of the refining stage

Set (variable ):

Unique, unordered, set () is converted into a set, removing duplicates.

Setx = set ([,]), sety = set ))

Add: setx. add (), add an element to it, setx. update ([2, 4, 3]), and add all the elements in the list to it (the Set will de-duplicate)

Delete: setx. remove (element): specifies who to delete. It is the same as discard (). However, if discart does not change the element in the collection, no error is reported. If discart does not change the element, remove will, setx. pop () randomly deletes one

 

Some methods:

Whether in, not in is in the collection,

Setx. intersection (sety): calculates the intersection of the two sets. You can also write it as setx & sety, setx. isdisjoint (sety) to determine whether there is no intersection between the two sets. If there is no intersection, True is returned.

Setx. union (sety): returns the union of the two sets, which can be written as setx | sety

Setx. difference (sety): calculate the difference set of the Two sets (in setx and no longer the sety element). It can be written as setx-sety.

Setx. equalric_difference (sety) is used to calculate the symmetric difference set of the two sets. if not all the elements of the two sets are in the Union-intersection, it can be written as setx ^ sety

Setx. issubset (sety), whether setx is a subset of sety, and whether issuperset () is a parent set

Len (setx), set. clear ()

 

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.