1 关键字参数
所用情形:参数太多时,防止参数顺序对函数的影响,传参时指定参数对应的形参名
>>> def test(brand,slogan):
print(brand + "'s slogan is " + slogan)
>>>test(brand='Nike',slogan='just do it')
Nike's slogan is just do it
2 默认参数
>>> def test(brand='Nike',slogan='just do it'):
print(brand + "'s slogan is " + slogan)
>>> test()
Nike's slogan is just do it
3 可变参数 参数前加 *
>>> def test(*params):
print('参数的长度是:',len(params) )
>>> test(1,2,3,4) #实现形式参数打包成元组
参数的长度是: 4