当前位置:网站首页>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
边栏推荐
- 2020.02.11
- Atcoder beginer contest 233 (a~d) solution
- MySQL winter vacation self-study 2022 11 (8)
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
- Master data management theory and Practice
- Briefly describe the implementation principle of redis cluster
- ReferenceError: primordials is not defined错误解决
- Introduction to robotframework (I) brief introduction and use
- 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
- CobaltStrike-4.4-K8修改版安装使用教程
猜你喜欢
Building the prototype of library functions -- refer to the manual of wildfire
PMP practice once a day | don't get lost in the exam -7.5
全国大学生信息安全赛创新实践赛初赛---misc(永恒的夜)
Apt installation ZABBIX
A copy can also produce flowers
MySQL winter vacation self-study 2022 11 (9)
Communication between microservices
2022 eye health exhibition, vision rehabilitation exhibition, optometry equipment exhibition, eye care products exhibition, eye mask Exhibition
Qt发布exe软件及修改exe应用程序图标
Blue Bridge Cup group B provincial preliminaries first question 2013 (Gauss Diary)
随机推荐
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.5 automatic differentiation_ Learning thinking and exercise answers
Qt发布exe软件及修改exe应用程序图标
力扣今日題-729. 我的日程安排錶 I
CSP numeric sort
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
不赚钱的科大讯飞,投资价值该怎么看?
Six stone management: why should leaders ignore product quality
DDoS "fire drill" service urges companies to be prepared
【Unity3D】GUI控件
QT release exe software and modify exe application icon
HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
从顶会论文看2022年推荐系统序列建模的趋势
Microsoft speech synthesis assistant v1.3 text to speech tool, real speech AI generator
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
Force buckle 146 LRU cache
Yyds dry inventory comparison of several database storage engines
DDoS attacks - are we really at war?
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
会员积分营销系统操作的时候怎样提升消费者的积极性?