图1.png
def foo(name,action='砍柴',where= '北京'):
print name,'去',where,action
foo('liyang','砍柴')
foo('laogou','xx')
foo('zxt','吃饭')
foo('fuxiao',where= '上海')
#写一个函数,并且接收一个参数。 但是在使用的时候传多个参数
def show(*arg):
for item in arg:
print item
show('liyang','zhangbing','zxt') #列表,传多个参数
##打印结果:
liyang
zhangbing
zxt
def show(**kargs):
for item in kargs.items(): #items函数
print item
user_dict = {'k1':123,'k2':456}
show(name='liyang',age='18') #字典,key-value的形式
show(**user_dict)
##打印结果:
('age', '18')
('name', 'liyang')
('k2', 456)
('k1', 123)
网友评论