python函数的参数定义和可变参数
来源:互联网 发布:工业企业利润数据 编辑:程序博客网 时间:2024/06/12 00:10
我们会经常看到 def func(*args, **kwargs)这类型的函数定义,今天做个笔记以免忘记。
*args表示,以元组的形式接收N个参数,例如:
def func(a, b, *args):
print a
print b
print args
func(1, 2, 3, 4, 5)
打印结果:
1
2
(3,4,5)
**kwargs表示,以字典的形式接收N个参数(在调用的时候要指定key),例如:
def func(a, b, **kwargs):
print a
print b
print kwargs
func(1, 2, c=3, d=4, e=5)
打印结果:
1
2
{'c': 3, 'e': 5, 'd': 4}
结束!
0 0
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python 函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- python函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- 转载-zookeeper在kafka中的作用
- ifconfig命令及网络接口
- Ajax 学习笔记
- com.genuitec.runtime.generic.jee70 is not defined
- mui.prompt怎么指定弹出框输入内容是input的类型,原始的type=text,
- python函数的参数定义和可变参数
- rpc
- 笨方法学python-class 10 input
- the content of element type must match解决方法
- mysql与oracle 表字段定义比较
- git 命令整理
- 接口与抽象类
- Volly的简单封装
- SpannableStringBuilder 同时设置setclickspan 和 ForegroundColorSpan出现问题