Concise Python Tutorial Learning Notes

Source: Internet
Author: User

Reference (Reference)

Do not know why not translated into a reference.

shoplist = [‘apple‘‘mango‘‘carrot‘‘banana‘]
mylist = shoplist 

In this case, MyList and Shoplist point to the same memory space. So what if you want to copy exactly one copy instead of quoting Shoplist?

MyList = shoplist[:]

Complete example

slicing (Slice)

Yesterday suddenly noticed the sequence of slices in front and back. Try it out, if it's a range of [3:2], then output an empty list. Of course [2:-1] This is no problem, 1 is meant to be the last.

The section of the slice is actually [), that is, before closing.

A fast online interpreter.

Default parameters

Only those parameters at the end of the formal parameter list can have default parameter values-that is, you cannot declare a formal parameter with a default value and then declare a formal parameter that has no default value when declaring a function parameter.
This is because the value assigned to the parameter is assigned according to the position. For example, def func(a, b=5) it is valid, but def func(a=5, b) it is not valid .

Key parameters

Advantage -one, since we don't have to worry about the order of the parameters, it's easier to use the function. Second, assuming that the other parameters have default values, we can only assign values to the parameters we want.

Concise Python Tutorial Learning Notes

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.