Baptism Soul, cultivation Python (16)--List of advanced topics--+copy module

Source: Internet
Author: User
Tags shallow copy

Homework after last lesson:

1. Using the list to parse the output: [(0,0), (0,2), (2,0), (2,2)]

Method 1:

Method 2:

Method 3:

2. Use the List Builder to print the Fibonacci sequence

3. Generating a list using list resolution [1x2,3x4,5x6,7x8,..., 99x100]

4. Use the 3-layer for-loop list generation to find the symmetric 3-digit number, for example: 121, left-to-right, or the original symmetry number

5. Write a function that accepts a list and then returns all the strings in the list to uppercase, and non-string elements are ignored

If you follow the usual wording:

Parsing by list is a lot easier:

Note that there is no change to the original list at this time

Copy module:

1. What is copy

Earlier in the list of shards to mention a little bit about the copy (copy), in this chapter will detail about the copy module

1. Use

Do a backup of the data, a little understanding of operations should have heard full backup and incremental backup it? In fact, the copy is used here, so in practical use, the copy is very common

3. Function (method):

See these methods, actually compared to the front, actually not much, right? Ignoring methods with special features is actually just a few, right?

However, the most common use of this module is copy and Deepcopy method, other basic rarely used, so directly skip

Copy: This method is a simple copy, similar to the common sense of the copy, it is another name called "Shallow copy" (or shallow copy), in other words is a copy of the parent object reference

Cases:

Deepcopy: This method is a bit more powerful than a shallow copy, which is called deep copy (or deep copy), in other words, a copy of the object's resources.

Summarize:

Shallow copy is the outermost copy of the original object, if there is a direct reference to the inner layer

A deep copy is a copy of the entire parameter resource of the original object, regardless of whether it has an inner layer or not, it has nothing to do with the original object

Is it really simple? Well, if you don't understand, practise more.

Baptism of souls, cultivation of Python (16)--List of advanced topics, previous work on +copy module

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.