0 Basic python-5.9 Set Set

Source: Internet
Author: User
Tags set set

Today, let's talk about set.

Collection: is an unordered set (collection) of some unique, immutable objects (numeric and string, etc.), and these objects support operations that correspond to the mathematical set theory.

Characteristics:

1. A single item can only appear once

2. Widespread use in digital and database work

3. Two sets cannot be added with +, but can use-subtract

Here are some of the operations of the collection, the middle section I deliberately use the + number, direct error


2. Some common methods in the collection



3. Note: Because the collection includes only immutable objects, lists and dictionaries cannot be embedded in the collection, and the collection cannot be embedded in the collection


4. Set resolution


5. Why do I need a collection

1) When traversing a back-type structure, the collection guarantees that the structure traverses only one side, because the collection only holds the object once

2) When querying a database, you need to compare two sets




Right here, thank you.

------------------------------------------------------------------

Click to jump 0 basic python-Catalogue

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

0 Basic python-5.9 Set Set

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.