函数def

不限定传入的值

  1. **kwargs:必须以字典方式传入
def a(name,**kwargs):
    print(f'name:{name},kwargs = {kwargs}')
    print(type(kwargs))

a(name = 'zhang',p ='f')

name:zhang,kwargs ={‘p’: ‘f’}
<class ‘dict’>

2.*args : 元组

def a(name,*args):
    print(f'name:{name},args = {args}')
    print(type(args))
a('zhang','f')

name:zhang,args = (‘f’,)
<class ‘tuple’>

上一篇:孤荷凌寒自学python第125天区块链039以太坊的 erc20代币09


下一篇:工具代码-timeout