Python Full Stack development 07

Source: Internet
Author: User
Tags shallow copy

collection (set)Collection, save a lot of data, can not repeat features: unordered, non-repeatable, content can be hashed, itself is not hash k = f Rozenset (collection): It's going to be a hash. Increase:S.add (content) s.update ("content"): Iterative additions Delete:
S.pop (): Randomly deletes one and returns the deletion of that content s.remove (' specified element '): Delete the specified element, if not present will error S.clear (): Empty collection, if print out empty collection will show set ({}) Modify:It's usually deleted and added. Check:Use a For loop to query common operations:
intersection:Print (S1 & S2): Returns the same element between them s1.intersection (S2) and set:
Print (S1 | s2): Returns a collection that includes all of their content, but does not repeat s1.union (S2): Difference SetPrint (S1-S2) s1.difference (S2): return s1 Remove and S2 have the same content. For example, s1{123},s2{3,4,5} returns { Depth Copy Normal CopyS1==S2, if S1 change, S2 will change. Shallow copy:Just a hash of the surface of the copy, copy the non-hash only copy memory address, so, their list is still variable s2 = s1.copy () Deep Copy:Import Copy # Introduction Module LS2 = Copy.deepcopy (1S1) # He's copying everything down, LS1 changes won't affect LS2

Python Full Stack development 07

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.