How to split list and pass them as separate parameter?

后端 未结 4 804
庸人自扰
庸人自扰 2020-12-05 06:52

My problem is I have values in a list. And I want to separate these values and send them as a separate parameter.

My code is:

def egg():
    return          


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 07:12

    >>> argList = ["egg1", "egg2"]
    >>> egg2(*argList)
    egg1
    egg2
    

    You can use *args (arguments) and **kwargs (for keyword arguments) when calling a function. Have a look at this blog on how to use it properly.

提交回复
热议问题