Python automation developed from shallow into deep-language Foundation (set)

Source: Internet
Author: User
Tags set set shallow copy

The concept of set is somewhat similar to a hash table, which is a set of elements that are unordered but not duplicated. Lists, Ganso, and dictionary data can be duplicated.

The set can be easily calculated and compared for intersection, difference, symmetry difference, and set, which is more complex in other sequence operations . .  

, a set set is created with the SET command:

         

    With the set defined, we can do the following:

      • Add an element, add an element 7

       

      • Add more than one element at a time, adding 7,9,11

       

      • Delete an element, remove the 5 in a

       

      • Find the length of the set, and find the length of 6

       

      • View whether a value is an element of another set, or is not a member of another set.

      • To see if all the elements of a set set are in another set,
       
      • Intersection of 2 set, {1,3}.

            

      • Set can go heavy, and the repeated 1,2,3,4 numbers are automatically removed.

         

      • Poor, b-a = {9,10,7}
       

    Symmetry difference: b^a, symmetric_difference removed 2 elements (opposite to the intersection).

    Sync Difference

     

    Ask for a hand

      • Combine union, B|a, remove duplicate elements, merge into a set

      • Asks if a set is in another set, and C,d is set in B.

      • Sets a string for the set conversion,
       

      • The copy of set is a shallow copy,

       

      • Pop is used to remove an indeterminate element from the set and return it,
       

      • Empty set,

     

    Python automation developed from shallow into deep-language Foundation (set)

    Related Article

    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.