Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the function knowledge points in python?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what are the knowledge points of functions in python, which are introduced in great detail and have certain reference value. Friends who are interested must finish reading them.

Two categories of function parameters the parameters written in parentheses in the definition stage of the function actual parameters in parentheses in the calling stage of the function the relationship of the parameter participating in the argument can be regarded as a variable name and the argument as a temporary binding in the phase of variable value function call. At the end of the function run, the expression form of the disconnected parameter variable name is various (grasp the core data value)

Position parameter position parameter from left to right parameter position parameter function definition stage from left to right variable name position argument function call stage fill in data value keyword argument (can break position order) function call stage passes value 1 in the form of formal parameter name = data value. The position shape participates in the position argument in the function call phase, according to the position corresponding binding 2. When binding position parameters, one more and one less is not important: the simpler the format, the more advanced the format, and the more complex the variable length parameter 1. No matter how many position parameters are passed into the function, the variable length parameter def func (xmemypenpena) can run normally: print (xmemypena) func () # () func (1) # (1,) func (1, 2, 4, 4, 5, 6, 7) # (1) func (1, 2) # 12 () func (1, 2, 4, 5, 5, 7, 8, 9) # 1, 2 (3, 4, 5, 7, 8) 6, 7, 8, 9) func (1) # 12 (3, 4, 5, 6, 7, 8, 9) * is used in formal parameters to receive excess positional parameters and organize row values into tuples to assign values to the variable name 2 after *. The function can run def index (x, y, * * b) no matter how many keywords are passed in: print (x, y, b) index () # {} index (x, y, b) index () # {} index: 1, 'baked: 2,' cages: 3, 'dudes: 4} index (yearly 2, xylene 1) # 12 {} index (yawning 2, xylene 1) # 12} index (yearly 2, xylene 1, upright 222, kink 111, lump 444) # 1 {' upright: 222,444) # 1 {'upright: 222,444) 'lforth: 444} * * is used in formal parameters to receive redundant keyword parameters and organize them to be assigned in the form of a dictionary to * * the variable names that follow * * use will scatter the data in lists and tuples * * use will break up dictionary key-value pairs into keyword parameters into namespace 1. The built-in namespace print () len () 2. The code written in the top box in the global namespace py file name = 'jason' # name global def func (): # func global pass if 1: a = 123 # a global for i in range (10): print (I) # I Global while True: a = 123 # a Global 3. After the local namespace function body code runs, all the local namespaces are generated.

These are all the contents of the article "what are the knowledge points of functions in python?" Thank you for your reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report