当前位置:网站首页>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
边栏推荐
- 解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
- HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
- Template_ Quick sort_ Double pointer
- [untitled] a query SQL execution process in the database
- 零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
- 07 singleton mode
- RobotFramework入门(一)简要介绍及使用
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
- Data preparation
- CSP numeric sort
猜你喜欢
随机推荐
The third level of C language punch in
How to check the lock information in gbase 8C database?
[untitled] a query SQL execution process in the database
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
Looking at the trend of sequence modeling of recommended systems in 2022 from the top paper
CobaltStrike-4.4-K8修改版安装使用教程
Maturity of master data management (MDM)
力扣今日題-729. 我的日程安排錶 I
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.3 linear algebra_ Learning thinking and exercise answers
2022 eye health exhibition, vision rehabilitation exhibition, optometry equipment exhibition, eye care products exhibition, eye mask Exhibition
全国大学生信息安全赛创新实践赛初赛---misc(永恒的夜)
JS events (add, delete) and delegates
Template_ Quick sort_ Double pointer
Data preparation
Follow the mouse's angle and keyboard events
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.5 automatic differentiation_ Learning thinking and exercise answers
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
How does yyds dry inventory deal with repeated messages in the consumption process?
Number conclusion LC skimming review - 1
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18









