zoukankan      html  css  js  c++  java
  • 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]
  • 相关阅读:
    Excel教程(5)
    Excel教程(4)
    Excel教程(3)
    Excel教程(2)
    如何在Excel中少犯二(I)
    for zip
    temp
    study
    eclipse
    shell
  • 原文地址:https://www.cnblogs.com/moonbaby/p/12202208.html
Copyright © 2011-2022 走看看