当前位置:网站首页>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():
pass
5. 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
边栏推荐
- 零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
- Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
- 如何精准识别主数据?
- CSP numeric sort
- Is there a case where sqlcdc monitors multiple tables and then associates them to sink to another table? All operations in MySQL
- ReferenceError: primordials is not defined错误解决
- 2022.02.13
- 事故指标统计
- DDoS "fire drill" service urges companies to be prepared
- 微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
猜你喜欢
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
Shell脚本更新存储过程到数据库
高数_向量代数_单位向量_向量与坐标轴的夹角
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
【若依(ruoyi)】启用迷你导航栏
Ue4- how to make a simple TPS role (II) - realize the basic movement of the role
Blue Bridge Cup group B provincial preliminaries first question 2013 (Gauss Diary)
淘宝焦点图布局实战
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
Keyword static
随机推荐
高数_向量代数_单位向量_向量与坐标轴的夹角
米家、涂鸦、Hilink、智汀等生态哪家强?5大主流智能品牌分析
I changed the driver to 5.1.35, but it is still the same error. I can succeed even now, but I will report this every time I do an SQL operation
PMP每日一练 | 考试不迷路-7.5
Template_ Quick sort_ Double pointer
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
QT release exe software and modify exe application icon
Fault analysis | analysis of an example of MySQL running out of host memory
【Unity3D】GUI控件
Large scale DDoS attacks take Myanmar offline
Network Security Learning - Web vulnerabilities (Part 1)
Microsoft speech synthesis assistant v1.3 text to speech tool, real speech AI generator
Maturity of master data management (MDM)
How to accurately identify master data?
Sword finger offer 30 Stack containing min function
在GBase 8c数据库中使用自带工具检查健康状态时,需要注意什么?
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
Is there a case where sqlcdc monitors multiple tables and then associates them to sink to another table? All operations in MySQL
Master data management theory and Practice
Keyword static