python 传参中的*和**

 1 def show_1(**kargs):
 2     for item in kargs.items():
 3         print(item)
 4 user_dict = {'k1':123,'k2':456}
 5 
 6 show_1(**user_dict)  #kargs=user_dict
 7 show_1(k1=123,k2=456,k3=789)  #kargs=dict(k1=123,k2=456,k3=789)
 8 
 9 
10 def show_2(*args):
11     for item in args:
12         print(item)
13 user_list = ['rain','cloud','sun']
14 
15 show_2(*user_list)  #args=user_list
16 show_2('rain','cloud')  #args=['rain','cloud']
17 show_2(user_list)  #args=[user_list]
posted @ 2020-01-16 17:01  Vincy_Wang  阅读(1574)  评论(0编辑  收藏  举报