1. 首页
  2. 数据库
  3. 其它
  4. Python入门09——函数的参数

Python入门09——函数的参数

上传者: 2020-12-22 23:46:37上传 PDF文件 54.02KB 热度 16次
在Python中,函数的参数主要可以分为以下三种类型: 1、可变参数 可变参数必须放在固定参数之后。 >>> def fun(a,b,*args): print(a,b,args) >>> fun(1,2,3,4,5) 1 2 (3, 4, 5) 2、关键字参数 必须成对传值:key = value >>> d = dict(one=1,two=2,three=3,four=4) >>> def fun(**kwargs): print(kwargs) >>> fun(**d) {'one': 1, 'two': 2, 'three': 3, 'four': 4} >>> fun(
下载地址
用户评论