Python Learning 12--Collection

Source: Internet
Author: User

1. Features of the collection
1). Unique. That is, the elements inside cannot be duplicated, but the statement does not give an error, but he will
Duplicate element to delete one.
2). Index acquisition is not supported. That is, the elements in the collection are unordered.
2. Creation of collections
1). Enclose some elements directly in curly braces. Example: num={1,2,3}
2). Created with the set () function. Set1=set ([+]), then set1={1,2,3}
3. Accessing values within a collection
1). Access by
2). Determine whether the presence is in the collection by in, not.
4. Adding, removing elements
Add (), remove ();
5. Immutable Collections
Frozenset (), used in a sense similar to set, is used to create an immutable collection where an element cannot be added or deleted.

Python Learning 12--Collection

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.