美文网首页
Python 中的 *args 和 **kwargs

Python 中的 *args 和 **kwargs

作者: 酷酷滴小爽哥 | 来源:发表于2018-08-28 17:17 被阅读0次

    带有这种参数的,实际传入参数时可以有多个,案例如下:

    def helloPython(*args,**kwargs):
        print ("non-key arguments are:")
        for a in args:
            print (a)
             
        print ("key-value arguments are:")
        for k,w in kwargs.items():
            print (k+"="+w)
     
    helloPython("I","know",whom = "you",what = "understand")
    

    相关文章

      网友评论

          本文标题:Python 中的 *args 和 **kwargs

          本文链接:https://www.haomeiwen.com/subject/vaeqwftx.html