Basic Python tutorial Sixth study notes

Source: Internet
Author: User

Collection functions

Collect actual parameters into tuples and dictionaries

1 defPrint_params (*params):2      Print(params)3 """4 Print_parasm (a)5 Output: (+/-)6 """7 8 defPrint_params_2 (* *params):9     Print(params)Ten  One """ A print_params_2 (X=1, y=2, z=3) - output:{' z ': 3, ' X ': 1, ' Y ': 2} - """

The *, * * operation can also be used to perform the opposite action

def Add (x, y    ): return x += (1, 2) Add (#  output:3

Calling a method when the name of the global variable and the local variable within the function are to be accessed by the function

1 #   This kind of operation is best not to use 2def  Combine (parameter):3     Print (Parameter + globals () ['parameter'])

def multiplier (factor):     def multiplybyfactor (number):         return number * factor    return  multiplybyfactor#   The function of the function that stores its scope, like Multiplybyfactor, is called a closure .

Basic Python tutorial Sixth study notes

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.