The method of parameters given in Python

理解Python函数参数与默认值
本文详细介绍了Python中函数参数的使用,包括位置参数、默认参数、关键字参数及组合参数的实现方式,并通过实例展示了如何正确应用这些特性。
  • def fun(self, a, b, c=None): The default value can be given, but must be given all in the rightest
  • def fun(self,a,b, *c): The group of parameters can be given, but only one of the default parameters and group parameters can be given. It conform to the logical. The group parameters is stored in a tuple.
  • When giving the parameters, if a is a list. fun(*a) is giving the element of a list to the function, fun(a) is giving a list to the function...
  • if b is a dictionary, fun(b) is giving a dictionary to the function, fun(*b) is giving the key of the dictionary to the function, fun(**b) is given the item of the dictionary to the function.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值