Python converting *args to list

后端 未结 3 1279
长情又很酷
长情又很酷 2021-02-07 14:34

This is what I\'m looking for:

def __init__(self, *args):
  list_of_args = #magic
  Parent.__init__(self, list_of_args)

I need to pass *args to

3条回答
  •  旧时难觅i
    2021-02-07 15:15

    If you're looking for something in the same direction as @simon 's solution, then:

    def test_args(*args): lists = [*args] print(lists) test_args([7],'eight',[[9]])

    Result:

    [[7], 'eight', [[9]]]

提交回复
热议问题