当前位置:网站首页>Function knowledge points
Function knowledge points
2022-07-06 02:43:00 【wwanxinghao】
Function definition : Encapsulate a specific function or code , When you need to use this function, you can call it directly
Parameters : When a function is called , Pass some information to the function
Parameter classification :
One . Shape parameter , At the time of function definition , You need to prepare some variables to receive information
1. Positional arguments , Declare variables one by one according to position
2. Default parameter , Give a default value when the function is declared , If the argument is not passed , The default value takes effect
3. Dynamic transfer parameters
1.*args, Indicates the dynamic transfer of all position parameters
2.**kwargs, It means to take over the dynamic parameters of all keywords
The order : Location >*args> The default value is >**kwargs
Two 、 Actual parameters : The information actually transmitted during electrophoresis
1. Positional arguments , Pass parameters by position
2. Key parameters , Pass parameters according to the name of the parameter
3. Mixing parameters :
The order : Put the position parameter in front , Key parameters after → Otherwise, the report will be wrong , The official setting is like this
Return value : After function execution , Will give the caller a result , The result is the return value
About return:
1. As long as the function executes return, The function immediately stops and returns the contents , Within the function return The subsequent code of will not be executed
2. If the function does not return, At this time, the outside world takes over None
3. If it's written return
1. Only written. retuan, Data is not followed , At this time, it is still None → amount to break
2.return value , At this time, the function has a return value , The outside world can take over a data → Most used
3.return value 1, value 2, value 3....., At this time, the function has multiple return values , The outside world receives tuples
Knowledge points to master function :
1. Nested function
2. Scope of variable
3. Closure
4. Decorator
# fn: A function ;inner,ret Just change the name
def wrapper(fn):
def inner(*args,**kwargs):
ret = fn(*args,**kwargs)
return ret
return inner()
@wrapper
def func():
pass5. iterator
6. generator
“ We can only go forward ”
yield
g = (x for x in xx)
7. The derived type
8. Anonymous functions
9.python Built in functions
边栏推荐
- Pat 1084 broken keyboard (20 points) string find
- Accident index statistics
- Template_ Quick sort_ Double pointer
- [Yu Yue education] basic reference materials of digital electronic technology of Xi'an University of Technology
- Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
- The third level of C language punch in
- 继承的构造函数
- Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8](/img/16/33f5623625ba817e6e022b5cb7ff5d.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8

HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据

"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.5 automatic differentiation_ Learning thinking and exercise answers

Which ecology is better, such as Mi family, graffiti, hilink, zhiting, etc? Analysis of five mainstream smart brands
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19](/img/7c/f728e88ca36524f92c56213370399b.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19

Sword finger offer 30 Stack containing min function

RobotFramework入门(一)简要介绍及使用

Network Security Learning - Web vulnerabilities (Part 1)

Black high-end responsive website dream weaving template (adaptive mobile terminal)

解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
随机推荐
MySQL winter vacation self-study 2022 11 (6)
RobotFramework入门(三)WebUI自动化之百度搜索
Sword finger offer 29 Print matrix clockwise
Template_ Find the reverse pair of permutations_ Sort based on merge
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
Patch NTP server at the beginning of DDoS counterattack
2022.02.13
Accident index statistics
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
How to accurately identify master data?
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
主数据管理理论与实践
UE4 - how to make a simple TPS role (I) - create a basic role
[Chongqing Guangdong education] higher mathematics I reference materials of Southwest Petroleum University
Y a - t - il des cas où sqlcdc surveille plusieurs tables et les associe à une autre? Tout fonctionne dans MySQL
RobotFramework入门(一)简要介绍及使用
2.11 simulation summary
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.3 linear algebra_ Learning thinking and exercise answers
[postgraduate entrance examination English] prepare for 2023, learn list5 words