函数之间传递list:

Python 函数传递list,传递dict 以及*args和**kargs
    




Python 函数传递list,传递dict 以及*args和**kargs
def show(ll):
    for i in ll:
        print(i)
         
show(['chen','hang','wang','yadan'])
#==========================================
chen
hang
wang
yadan
Python 函数传递list,传递dict 以及*args和**kargs
    




Python 函数传递list,传递dict 以及*args和**kargs

 

*args:输入数据长度不确定,通过*args将任意长度的参数传递给函数,系统自动将任意长度参数用list(tuple定长,特殊的list)表示

Python 函数传递list,传递dict 以及*args和**kargs
    




Python 函数传递list,传递dict 以及*args和**kargs
def show(*args):
    for i in args:
        print(i)
        
show('chen','hang','wang','yadan')
#=============================================
chen
hang
wang
yadan
Python 函数传递list,传递dict 以及*args和**kargs
    




Python 函数传递list,传递dict 以及*args和**kargs

**kargs:输入数据长度不确定,系统自动将任意长度参数用dict(字典)表示

Python 函数传递list,传递dict 以及*args和**kargs
    




Python 函数传递list,传递dict 以及*args和**kargs
def show(**kargs):
    for i in kargs.items():
        print(i)

show(name='hangge',age=25,sex='man',school='wust')
#============================================
('name', 'hangge')
('school', 'wust')
('sex', 'man')
('age', 25)
Python 函数传递list,传递dict 以及*args和**kargs
    




Python 函数传递list,传递dict 以及*args和**kargs

函数之间传递dict:

def show(**kargs):
    .....

user={‘chen’:1,'hang':2,'wangyadan':3}
show(**user)

相关文章:

  • 2022-12-23
  • 2021-10-21
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-06-20
  • 2021-08-22
猜你喜欢
  • 2021-07-25
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2021-12-26
  • 2021-05-25
  • 2022-12-23
相关资源
相似解决方案