Python Learn how to create and base operations on the 15th day collection

Source: Internet
Author: User

A collection is a Python-unique list of data that can be analyzed by the collection, which is an unordered, unique data type that determines the uniqueness of the list, and the creation of the collection and basic common methods of operation.

1, creation of the collection

s={1,2,4}

You can also create a collection with Set ()

2, the basic operation method of the collection

s1={2,3,4,6}

S1.add (5) Add an element

S1.pop () randomly deletes an element

S1.remove (4) error occurs when a nonexistent data is present

S1.discard (4) No error occurs when a nonexistent data is present

S1.update ({)}) Extended Data collection

S1.clear () Clears collection data

Article reprint (JIU le network http://www.96net.com.cn/)

Python Learn how to create and base operations on the 15th day collection

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.